Skip to contentSkip to conversation

clean up physical merging helpers

PATCH New Christoph Hellwig 2 participants 7 messages Sep 25, 2018 – Sep 26, 2018

Subsystems (6)
Arm (32-bit) x86 Block layer arm64 +2 more subsystems
lore
Share & tools
lore
#0 lore raw

Hi Jens,

this series moves Xen special handling of block merges from arch hooks into common code. A previous version has been reviewed by Boris.

#1 lore raw

PATCH 1/5 arm: remove the unused BIOVEC_MERGEABLE define

---
 arch/arm/include/asm/io.h | 7 -------
 1 file changed, 7 deletions(-)
arch/arm/include/asm/io.h +0 -7
index 3c835d6263fa..e58ca25eddb7 100644
@@ -459,13 +459,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
 
 #include <asm-generic/io.h>
 
-/*
- * can the hardware map this into one segment or not, given no other
- * constraints.
- */
-#define BIOVEC_MERGEABLE(vec1, vec2)	\
-	((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
-
 struct bio_vec;
 extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 				      const struct bio_vec *vec2);
Signature · 1 line
2.19.0
#2 lore raw

PATCH 2/5 xen: remove the xen_biovec_phys_mergeable export

In reply to Christoph Hellwig

BIOVEC_PHYS_MERGEABLE is only called from core block code.

---
 drivers/xen/biomerge.c | 1 -
 1 file changed, 1 deletion(-)
drivers/xen/biomerge.c +0 -1
index 55ed80c3a17c..399c4e30f723 100644
@@ -20,4 +20,3 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 	return false;
 #endif
 }
-EXPORT_SYMBOL(xen_biovec_phys_mergeable);
Signature · 1 line
2.19.0
#3 lore raw

PATCH 3/5 xen: provide a prototype for xen_biovec_phys_mergeable in xen.h

In reply to Christoph Hellwig

Having multiple externs in arch headers is not a good way to provide a common interface.

---
 arch/arm/include/asm/io.h   | 3 ---
 arch/arm64/include/asm/io.h | 3 ---
 arch/x86/include/asm/io.h   | 4 ----
 include/xen/xen.h           | 4 ++++
 4 files changed, 4 insertions(+), 10 deletions(-)
arch/arm/include/asm/io.h +0 -3
index e58ca25eddb7..cf5cd88e7289 100644
@@ -459,9 +459,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
 
 #include <asm-generic/io.h>
 
-struct bio_vec;
-extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
-				      const struct bio_vec *vec2);
 #define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
 	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
 
arch/arm64/include/asm/io.h +0 -3
index 774e03ea1bb0..06119ee511cd 100644
@@ -205,9 +205,6 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
 
 extern int devmem_is_allowed(unsigned long pfn);
 
-struct bio_vec;
-extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
-				      const struct bio_vec *vec2);
 #define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
 	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
 
arch/x86/include/asm/io.h +0 -4
index 7c6106216d9c..abdb501a551d 100644
@@ -371,10 +371,6 @@ extern bool is_early_ioremap_ptep(pte_t *ptep);
 
 #ifdef CONFIG_XEN
 #include <xen/xen.h>
-struct bio_vec;
-
-extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
-				      const struct bio_vec *vec2);
 
 #define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
 	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
include/xen/xen.h +4 -0
index 1e1d9bd0bd37..d7a2678da77f 100644
@@ -39,4 +39,8 @@ extern uint32_t xen_start_flags;
 #define xen_initial_domain()	(0)
 #endif	/* CONFIG_XEN_DOM0 */
 
+struct bio_vec;
+bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
+		const struct bio_vec *vec2);
+
 #endif	/* _XEN_XEN_H */
Signature · 1 line
2.19.0
#4 lore raw

PATCH 4/5 block: remove ARCH_BIOVEC_PHYS_MERGEABLE

In reply to Christoph Hellwig

Take the Xen check into the core code instead of delegating it to the architectures.

---
 arch/arm/include/asm/io.h   | 3 ---
 arch/arm64/include/asm/io.h | 3 ---
 arch/x86/include/asm/io.h   | 3 ---
 block/blk.h                 | 7 ++-----
 drivers/xen/biomerge.c      | 2 +-
 5 files changed, 3 insertions(+), 15 deletions(-)
arch/arm/include/asm/io.h +0 -3
index cf5cd88e7289..6ae7674da0d6 100644
@@ -459,9 +459,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
 
 #include <asm-generic/io.h>
 
-#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
-	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
-
 #ifdef CONFIG_MMU
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
 extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
arch/arm64/include/asm/io.h +0 -3
index 06119ee511cd..18f6ae6a43f1 100644
@@ -205,8 +205,5 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
 
 extern int devmem_is_allowed(unsigned long pfn);
 
-#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
-	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
-
 #endif	/* __KERNEL__ */
 #endif	/* __ASM_IO_H */
arch/x86/include/asm/io.h +0 -3
index abdb501a551d..232d8e9ee8a0 100644
@@ -371,9 +371,6 @@ extern bool is_early_ioremap_ptep(pte_t *ptep);
 
 #ifdef CONFIG_XEN
 #include <xen/xen.h>
-
-#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)				\
-	 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
 #endif	/* CONFIG_XEN */
 
 #define IO_SPACE_LIMIT 0xffff
block/blk.h +2 -5
index 50f74ce60453..58c030f727e9 100644
@@ -4,6 +4,7 @@
 
 #include <linux/idr.h>
 #include <linux/blk-mq.h>
+#include <xen/xen.h>
 #include "blk-mq.h"
 
 /* Amount of time in which a process may batch requests */
@@ -149,10 +150,6 @@ static inline void blk_queue_enter_live(struct request_queue *q)
 	percpu_ref_get(&q->q_usage_counter);
 }
 
-#ifndef ARCH_BIOVEC_PHYS_MERGEABLE
-#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) true
-#endif
-
 static inline bool biovec_phys_mergeable(struct request_queue *q,
 		struct bio_vec *vec1, struct bio_vec *vec2)
 {
@@ -162,7 +159,7 @@ static inline bool biovec_phys_mergeable(struct request_queue *q,
 
 	if (addr1 + vec1->bv_len != addr2)
 		return false;
-	if (!ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2))
+	if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2))
 		return false;
 	if ((addr1 | mask) != ((addr2 + vec2->bv_len - 1) | mask))
 		return false;
drivers/xen/biomerge.c +1 -1
index 399c4e30f723..f3fbb700f569 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/bio.h>
-#include <linux/io.h>
 #include <linux/export.h>
+#include <xen/xen.h>
 #include <xen/page.h>
 
 bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
Signature · 1 line
2.19.0
#5 lore raw

PATCH 5/5 xen: don't include <xen/xen.h> from <asm/io.h> and <asm/dma-mapping.h>

In reply to Christoph Hellwig

Nothing Xen specific in these headers, which get included from a lot of code in the kernel. So prune the includes and move them to the Xen-specific files that actually use them instead.

---
 arch/arm/include/asm/io.h          | 1 -
 arch/arm64/include/asm/io.h        | 2 --
 arch/x86/include/asm/io.h          | 4 ----
 arch/x86/include/asm/xen/events.h  | 2 ++
 arch/x86/xen/enlighten.c           | 1 +
 arch/x86/xen/enlighten_pvh.c       | 1 +
 arch/x86/xen/platform-pci-unplug.c | 1 +
 arch/x86/xen/pmu.c                 | 1 +
 drivers/xen/xen-acpi-pad.c         | 1 +
 9 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/include/asm/io.h +0 -1
index 6ae7674da0d6..6b51826ab3d1 100644
@@ -28,7 +28,6 @@
 #include <asm/byteorder.h>
 #include <asm/memory.h>
 #include <asm-generic/pci_iomap.h>
-#include <xen/xen.h>
 
 /*
  * ISA I/O bus memory addresses are 1:1 with the physical address.
arch/arm64/include/asm/io.h +0 -2
index 18f6ae6a43f1..9f8b915af3a7 100644
@@ -31,8 +31,6 @@
 #include <asm/alternative.h>
 #include <asm/cpufeature.h>
 
-#include <xen/xen.h>
-
 /*
  * Generic IO read/write.  These perform native-endian accesses.
  */
arch/x86/include/asm/io.h +0 -4
index 232d8e9ee8a0..9a92a3ac2ac5 100644
@@ -369,10 +369,6 @@ extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
 
 extern bool is_early_ioremap_ptep(pte_t *ptep);
 
-#ifdef CONFIG_XEN
-#include <xen/xen.h>
-#endif	/* CONFIG_XEN */
-
 #define IO_SPACE_LIMIT 0xffff
 
 #include <asm-generic/io.h>
arch/x86/include/asm/xen/events.h +2 -0
index d383140e1dc8..068d9b067c83 100644
@@ -2,6 +2,8 @@
 #ifndef _ASM_X86_XEN_EVENTS_H
 #define _ASM_X86_XEN_EVENTS_H
 
+#include <xen/xen.h>
+
 enum ipi_vector {
 	XEN_RESCHEDULE_VECTOR,
 	XEN_CALL_FUNCTION_VECTOR,
arch/x86/xen/enlighten.c +1 -0
index 2eeddd814653..0ca46e03b830 100644
@@ -5,6 +5,7 @@
 #include <linux/kexec.h>
 #include <linux/slab.h>
 
+#include <xen/xen.h>
 #include <xen/features.h>
 #include <xen/page.h>
 #include <xen/interface/memory.h>
arch/x86/xen/enlighten_pvh.c +1 -0
index c85d1a88f476..2a9025343534 100644
@@ -11,6 +11,7 @@
 #include <asm/xen/interface.h>
 #include <asm/xen/hypercall.h>
 
+#include <xen/xen.h>
 #include <xen/interface/memory.h>
 #include <xen/interface/hvm/start_info.h>
 
arch/x86/xen/platform-pci-unplug.c +1 -0
index 33a783c77d96..b99585034dd2 100644
@@ -23,6 +23,7 @@
 #include <linux/io.h>
 #include <linux/export.h>
 
+#include <xen/xen.h>
 #include <xen/platform_pci.h>
 #include "xen-ops.h"
 
arch/x86/xen/pmu.c +1 -0
index 7d00d4ad44d4..5f7d530fc679 100644
@@ -3,6 +3,7 @@
 #include <linux/interrupt.h>
 
 #include <asm/xen/hypercall.h>
+#include <xen/xen.h>
 #include <xen/page.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/vcpu.h>
drivers/xen/xen-acpi-pad.c +1 -0
index 23d1808fe027..e25ab76b9c99 100644
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
+#include <xen/xen.h>
 #include <xen/interface/version.h>
 #include <xen/xen-ops.h>
 #include <asm/xen/hypercall.h>
Signature · 1 line
2.19.0
maintainer Applied
#6 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

Hi Jens,

this series moves Xen special handling of block merges from arch hooks into common code. A previous version has been reviewed by Boris.

Applied, thanks.

Signature · 1 line
Jens Axboe