clean up physical merging helpers
Subsystems (7)
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.
PATCH 1/13 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
@@ -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.18.0
PATCH 2/13 xen: remove the xen_biovec_phys_mergeable export
In reply to Christoph HellwigBIOVEC_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
@@ -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.18.0
PATCH 2/13 xen: remove the xen_biovec_phys_mergeable export
In reply to Christoph HellwigBIOVEC_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
@@ -20,4 +20,3 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,return false;#endif } -EXPORT_SYMBOL (xen_biovec_phys_mergeable);
Signature · 7 lines
2.18.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/13 xen: provide a prototype for xen_biovec_phys_mergeable in xen.h
In reply to Christoph HellwigHaving 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 | 5 ----- include/xen/xen.h | 4 ++++ 4 files changed, 4 insertions(+), 11 deletions(-)
arch/arm/include/asm/io.h +0 -3
@@ -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 BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
arch/arm64/include/asm/io.h +0 -3
@@ -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 BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
arch/x86/include/asm/io.h +0 -5
@@ -371,11 +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 BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
include/xen/xen.h +4 -0
@@ -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.18.0
PATCH 4/13 block: move integrity_req_gap_{back,front}_merge to blk.h
In reply to Christoph HellwigNo need to expose these to drivers.
--- block/blk.h | 35 +++++++++++++++++++++++++++++++++-- include/linux/blkdev.h | 31 ------------------------------- 2 files changed, 33 insertions(+), 33 deletions(-)
block/blk.h +33 -2
@@ -158,7 +158,38 @@ static inline bool bio_integrity_endio(struct bio *bio)return __bio_integrity_endio (bio);return true; } -#else + +static inline bool integrity_req_gap_back_merge (struct request *req, +struct bio *next) +{ +struct bio_integrity_payload *bip =bio_integrity (req->bio); +struct bio_integrity_payload *bip_next =bio_integrity (next); + +return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], + bip_next->bip_vec[0 ].bv_offset); +} + +static inline bool integrity_req_gap_front_merge (struct request *req, +struct bio *bio) +{ +struct bio_integrity_payload *bip =bio_integrity (bio); +struct bio_integrity_payload *bip_next =bio_integrity (req->bio); + +return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], + bip_next->bip_vec[0 ].bv_offset); +} +#else /* CONFIG_BLK_DEV_INTEGRITY */ +static inline bool integrity_req_gap_back_merge (struct request *req, +struct bio *next) +{ +return false; +} +static inline bool integrity_req_gap_front_merge (struct request *req, +struct bio *bio) +{ +return false; +} +static inline void blk_flush_integrity (void ) { }
@@ -166,7 +197,7 @@ static inline bool bio_integrity_endio(struct bio *bio) {return true; } -#endif +#endif /* CONFIG_BLK_DEV_INTEGRITY */ void blk_timeout_work (struct work_struct *work);unsigned long blk_rq_timeout (unsigned long timeout);
include/linux/blkdev.h +0 -31
@@ -1843,26 +1843,6 @@ queue_max_integrity_segments(struct request_queue *q)return q->limits.max_integrity_segments; } -static inline bool integrity_req_gap_back_merge (struct request *req, -struct bio *next) -{ -struct bio_integrity_payload *bip =bio_integrity (req->bio); -struct bio_integrity_payload *bip_next =bio_integrity (next); - -return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], - bip_next->bip_vec[0 ].bv_offset); -} - -static inline bool integrity_req_gap_front_merge (struct request *req, -struct bio *bio) -{ -struct bio_integrity_payload *bip =bio_integrity (bio); -struct bio_integrity_payload *bip_next =bio_integrity (req->bio); - -return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], - bip_next->bip_vec[0 ].bv_offset); -} -/** * bio_integrity_intervals - Return number of integrity intervals for a bio * @bi: blk_integrity profile for device
@@ -1947,17 +1927,6 @@ static inline bool blk_integrity_merge_bio(struct request_queue *rq,return true; } -static inline bool integrity_req_gap_back_merge (struct request *req, -struct bio *next) -{ -return false; -} -static inline bool integrity_req_gap_front_merge (struct request *req, -struct bio *bio) -{ -return false; -} -static inline unsigned int bio_integrity_intervals (struct blk_integrity *bi,unsigned int sectors) {
Signature · 1 line
2.18.0
PATCH 5/13 block: move req_gap_{back,front}_merge to blk-merge.c
In reply to Christoph HellwigKeep it close to the actual users instead of exposing the function to all drivers.
--- block/blk-merge.c | 65 +++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 69 ------------------------------------------ 2 files changed, 65 insertions(+), 69 deletions(-)
block/blk-merge.c +65 -0
@@ -12,6 +12,71 @@#include "blk.h" +/* +* Check if the two bvecs from two bios can be merged to one segment. If yes, +* no need to check gap between the two bios since the 1st bio and the 1st bvec +* in the 2nd bio can be handled in one segment. +*/ +static inline bool bios_segs_mergeable (struct request_queue *q, +struct bio *prev,struct bio_vec *prev_last_bv, +struct bio_vec *next_first_bv) +{ +if (!BIOVEC_PHYS_MERGEABLE (prev_last_bv, next_first_bv)) +return false; +if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv)) +return false; +if (prev->bi_seg_back_size + next_first_bv->bv_len > +queue_max_segment_size (q)) +return false; +return true; +} + +static inline bool bio_will_gap (struct request_queue *q, +struct request *prev_rq,struct bio *prev,struct bio *next) +{ +struct bio_vec pb, nb; + +if (!bio_has_data (prev) || !queue_virt_boundary (q)) +return false; + +/* +* Don't merge if the 1st bio starts with non-zero offset, otherwise it +* is quite difficult to respect the sg gap limit. We work hard to +* merge a huge number of small single bios in case of mkfs. +*/ +if (prev_rq) +bio_get_first_bvec (prev_rq->bio, &pb); +else +bio_get_first_bvec (prev, &pb); +if (pb.bv_offset) +return true; + +/* +* We don't need to worry about the situation that the merged segment +* ends in unaligned virt boundary: +* +* - if 'pb' ends aligned, the merged segment ends aligned +* - if 'pb' ends unaligned, the next bio must include +* one single bvec of 'nb', otherwise the 'nb' can't +* merge with 'pb' +*/ +bio_get_last_bvec (prev, &pb); +bio_get_first_bvec (next, &nb); +if (bios_segs_mergeable (q, prev, &pb, &nb)) +return false; +return __bvec_gap_to_prev (q, &pb, nb.bv_offset); +} + +static inline bool req_gap_back_merge (struct request *req,struct bio *bio) +{ +return bio_will_gap (req->q, req, req->biotail, bio); +} + +static inline bool req_gap_front_merge (struct request *req,struct bio *bio) +{ +return bio_will_gap (req->q,NULL , bio, req->bio); +} + static struct bio *blk_bio_discard_split(struct request_queue *q, struct bio *bio, struct bio_set *bs,
include/linux/blkdev.h +0 -69
75 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 6/13 block: move req_gap_back_merge to blk.h
In reply to Christoph HellwigNo need to expose these helpers outside the block layer.
--- block/blk.h | 19 +++++++++++++++++++ include/linux/blkdev.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-)
block/blk.h +19 -0
@@ -149,6 +149,25 @@ static inline void blk_queue_enter_live(struct request_queue *q)percpu_ref_get (&q->q_usage_counter); } +static inline bool __bvec_gap_to_prev (struct request_queue *q, +struct bio_vec *bprv,unsigned int offset) +{ +return offset || + ((bprv->bv_offset + bprv->bv_len) &queue_virt_boundary (q)); +} + +/* +* Check if adding a bio_vec after bprv with offset would create a gap in +* the SG list. Most drivers don't care about this, but some do. +*/ +static inline bool bvec_gap_to_prev (struct request_queue *q, +struct bio_vec *bprv,unsigned int offset) +{ +if (!queue_virt_boundary (q)) +return false; +return __bvec_gap_to_prev (q, bprv, offset); +} +#ifdef CONFIG_BLK_DEV_INTEGRITY void blk_flush_integrity (void );bool __bio_integrity_endio (struct bio *);
include/linux/blkdev.h +0 -19
@@ -1676,25 +1676,6 @@ static inline void put_dev_sector(Sector p)put_page (p.v); } -static inline bool __bvec_gap_to_prev (struct request_queue *q, -struct bio_vec *bprv,unsigned int offset) -{ -return offset || - ((bprv->bv_offset + bprv->bv_len) &queue_virt_boundary (q)); -} - -/* -* Check if adding a bio_vec after bprv with offset would create a gap in -* the SG list. Most drivers don't care about this, but some do. -*/ -static inline bool bvec_gap_to_prev (struct request_queue *q, -struct bio_vec *bprv,unsigned int offset) -{ -if (!queue_virt_boundary (q)) -return false; -return __bvec_gap_to_prev (q, bprv, offset); -} -int kblockd_schedule_work (struct work_struct *work);int kblockd_schedule_work_on (int cpu,struct work_struct *work);int kblockd_mod_delayed_work_on (int cpu,struct delayed_work *dwork,unsigned long delay);
Signature · 1 line
2.18.0
PATCH 7/13 block: simplify BIOVEC_PHYS_MERGEABLE
In reply to Christoph HellwigTurn the macro into an inline, move it to blk.h and take the Xen check into the core code instead of delegating it to architectures.
Also rename the function to biovec_phys_mergeable as there is no need to shout.
--- arch/arm/include/asm/io.h | 4 ---- arch/arm64/include/asm/io.h | 4 ---- arch/x86/include/asm/io.h | 3 --- block/bio.c | 2 +- block/blk-integrity.c | 4 ++-- block/blk-merge.c | 10 +++++----- block/blk.h | 11 +++++++++++ drivers/xen/biomerge.c | 2 +- include/linux/bio.h | 13 ------------- 9 files changed, 20 insertions(+), 33 deletions(-)
arch/arm/include/asm/io.h +0 -4
@@ -459,10 +459,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);#include <asm-generic/io.h> -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__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 -4
@@ -205,9 +205,5 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);extern int devmem_is_allowed (unsigned long pfn); -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__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
@@ -371,9 +371,6 @@ extern bool is_early_ioremap_ptep(pte_t *ptep);#ifdef CONFIG_XEN #include <xen/xen.h> -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ - (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))#endif /* CONFIG_XEN */ #define IO_SPACE_LIMIT 0xffff
block/bio.c +1 -1
@@ -729,7 +729,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 && (BIOVEC_PHYS_MERGEABLE (bvec-1 , bvec))) +if (bio->bi_vcnt >1 &&biovec_phys_mergeable (bvec-1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
block/blk-integrity.c +2 -2
@@ -49,7 +49,7 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!BIOVEC_PHYS_MERGEABLE (&ivprv, &iv)) +if (!biovec_phys_mergeable (&ivprv, &iv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv))
@@ -95,7 +95,7 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!BIOVEC_PHYS_MERGEABLE (&ivprv, &iv)) +if (!biovec_phys_mergeable (&ivprv, &iv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv))
block/blk-merge.c +5 -5
@@ -21,7 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q, struct bio *prev, struct bio_vec *prev_last_bv, struct bio_vec *next_first_bv) { - if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv)) + if (!biovec_phys_mergeable(prev_last_bv, next_first_bv)) return false;if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv))return false;
@@ -199,7 +199,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,if (bvprvp &&blk_queue_cluster (q)) {if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (bvprvp, &bv)) +if (!biovec_phys_mergeable (bvprvp, &bv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, bvprvp, &bv)) goto new_segment;
@@ -332,7 +332,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (&bvprv, &bv)) +if (!biovec_phys_mergeable (&bvprv, &bv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &bvprv, &bv)) goto new_segment;
@@ -414,7 +414,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,bio_get_last_bvec (bio, &end_bv);bio_get_first_bvec (nxt, &nxt_bv); -if (!BIOVEC_PHYS_MERGEABLE (&end_bv, &nxt_bv)) +if (!biovec_phys_mergeable (&end_bv, &nxt_bv))return 0 ;/*
@@ -439,7 +439,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,if ((*sg)->length + nbytes >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (bvprv, bvec)) +if (!biovec_phys_mergeable (bvprv, bvec)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, bvprv, bvec)) goto new_segment;
block/blk.h +11 -0
@@ -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,6 +150,16 @@ static inline void blk_queue_enter_live(struct request_queue *q)percpu_ref_get (&q->q_usage_counter); } +static inline bool biovec_phys_mergeable (const struct bio_vec *vec1, +const struct bio_vec *vec2) +{ +if (bvec_to_phys (vec1) + vec1->bv_len !=bvec_to_phys (vec2)) +return false; +if (xen_domain () && !xen_biovec_phys_mergeable (vec1, vec2)) +return false; +return true; +} +static inline bool __bvec_gap_to_prev (struct request_queue *q,struct bio_vec *bprv,unsigned int offset) {
drivers/xen/biomerge.c +1 -1
@@ -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,
include/linux/bio.h +0 -13
@@ -140,19 +140,6 @@ static inline bool bio_full(struct bio *bio)/* * merge helpers etc */ - -/* Default implementation of BIOVEC_PHYS_MERGEABLE */ -#define __BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) - -/* -* allow arch override, for eg virtualized architectures (put in asm/io.h) -*/ -#ifndef BIOVEC_PHYS_MERGEABLE -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - __BIOVEC_PHYS_MERGEABLE(vec1, vec2) -#endif -#define __BIO_SEG_BOUNDARY (addr1, addr2, mask) \ (((addr1) | (mask)) == (((addr2) - 1) | (mask)))#define BIOVEC_SEG_BOUNDARY (q, b1, b2) \
Signature · 1 line
2.18.0
PATCH 8/13 block: add a missing BIOVEC_SEG_BOUNDARY check in bio_add_pc_page
In reply to Christoph HellwigThe actual recaculation of segments in __blk_recalc_rq_segments will do this check, so there is no point in forcing it if we know it won't succeed.
--- block/bio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/bio.c +3 -1
@@ -729,7 +729,9 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 &&biovec_phys_mergeable (bvec-1 , bvec)) +if (bio->bi_vcnt >1 && +biovec_phys_mergeable (bvec -1 , bvec) && +BIOVEC_SEG_BOUNDARY (q, bvec -1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
Signature · 1 line
2.18.0
PATCH 9/13 block: merge BIOVEC_SEG_BOUNDARY into biovec_phys_mergeable
In reply to Christoph HellwigThese two checks should always be performed together, so merge them into a single helper.
--- block/bio.c | 4 +--- block/blk-integrity.c | 12 ++---------- block/blk-merge.c | 29 +++++------------------------ block/blk.h | 12 +++++++++--- include/linux/bio.h | 8 -------- 5 files changed, 17 insertions(+), 48 deletions(-)
block/bio.c +1 -3
@@ -729,9 +729,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 && -biovec_phys_mergeable (bvec -1 , bvec) && -BIOVEC_SEG_BOUNDARY (q, bvec -1 , bvec)) +if (bio->bi_vcnt >1 &&biovec_phys_mergeable (q, bvec -1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
block/blk-integrity.c +2 -10
@@ -49,12 +49,8 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!biovec_phys_mergeable (&ivprv, &iv)) +if (!biovec_phys_mergeable (q, &ivprv, &iv)) goto new_segment; - -if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv)) - goto new_segment; -if (seg_size + iv.bv_len >queue_max_segment_size (q)) goto new_segment;
@@ -95,12 +91,8 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!biovec_phys_mergeable (&ivprv, &iv)) +if (!biovec_phys_mergeable (q, &ivprv, &iv)) goto new_segment; - -if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv)) - goto new_segment; -if (sg->length + iv.bv_len >queue_max_segment_size (q)) goto new_segment;
block/blk-merge.c +5 -24
@@ -21,9 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q, struct bio *prev, struct bio_vec *prev_last_bv, struct bio_vec *next_first_bv) { - if (!biovec_phys_mergeable(prev_last_bv, next_first_bv)) - return false; -if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv)) + if (!biovec_phys_mergeable(q, prev_last_bv, next_first_bv)) return false;if (prev->bi_seg_back_size + next_first_bv->bv_len >queue_max_segment_size (q))
@@ -199,9 +197,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,if (bvprvp &&blk_queue_cluster (q)) {if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!biovec_phys_mergeable (bvprvp, &bv)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, bvprvp, &bv)) +if (!biovec_phys_mergeable (q, bvprvp, &bv)) goto new_segment; seg_size += bv.bv_len;
@@ -332,9 +328,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!biovec_phys_mergeable (&bvprv, &bv)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, &bvprv, &bv)) +if (!biovec_phys_mergeable (q, &bvprv, &bv)) goto new_segment; seg_size += bv.bv_len;
@@ -414,17 +408,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,bio_get_last_bvec (bio, &end_bv);bio_get_first_bvec (nxt, &nxt_bv); -if (!biovec_phys_mergeable (&end_bv, &nxt_bv)) -return 0 ; - -/* -* bio and nxt are contiguous in memory; check if the queue allows -* these two to be merged into one -*/ -if (BIOVEC_SEG_BOUNDARY (q, &end_bv, &nxt_bv)) -return 1 ; - -return 0 ; +return biovec_phys_mergeable (q, &end_bv, &nxt_bv); } static inline void
@@ -438,10 +422,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,if (*sg && *cluster) {if ((*sg)->length + nbytes >queue_max_segment_size (q)) goto new_segment; - -if (!biovec_phys_mergeable (bvprv, bvec)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, bvprv, bvec)) +if (!biovec_phys_mergeable (q, bvprv, bvec)) goto new_segment; (*sg)->length += nbytes;
block/blk.h +9 -3
@@ -150,13 +150,19 @@ static inline void blk_queue_enter_live(struct request_queue *q)percpu_ref_get (&q->q_usage_counter); } -static inline bool biovec_phys_mergeable (const struct bio_vec *vec1, -const struct bio_vec *vec2) +static inline bool biovec_phys_mergeable (struct request_queue *q, +struct bio_vec *vec1,struct bio_vec *vec2) { -if (bvec_to_phys (vec1) + vec1->bv_len !=bvec_to_phys (vec2)) +unsigned long mask =queue_segment_boundary (q); +phys_addr_t addr1 =bvec_to_phys (vec1); +phys_addr_t addr2 =bvec_to_phys (vec2); + +if (addr1 + vec1->bv_len != addr2)return false;if (xen_domain () && !xen_biovec_phys_mergeable (vec1, vec2))return false; +if ((addr1 | mask) != ((addr2 + vec2->bv_len -1 ) | mask)) +return false;return true; }
include/linux/bio.h +0 -8
@@ -137,14 +137,6 @@ static inline bool bio_full(struct bio *bio)*/ #define bvec_to_phys (bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset) -/* -* merge helpers etc -*/ -#define __BIO_SEG_BOUNDARY (addr1, addr2, mask) \ - (((addr1) | (mask)) == (((addr2) - 1) | (mask))) -#define BIOVEC_SEG_BOUNDARY (q, b1, b2) \ - __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, queue_segment_boundary((q))) -/* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it
Signature · 1 line
2.18.0
PATCH 10/13 block: remove bvec_to_phys
In reply to Christoph HellwigWe only use it in biovec_phys_mergeable and a m68k paravirt driver, so just opencode it there. Also remove the pointless unsigned long cast for the offset in the opencoded instances.
--- arch/m68k/emu/nfblock.c | 2 +- block/blk.h | 4 ++-- include/linux/bio.h | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-)
arch/m68k/emu/nfblock.c +1 -1
@@ -73,7 +73,7 @@ static blk_qc_t nfhd_make_request(struct request_queue *queue, struct bio *bio) len = bvec.bv_len; len >>=9 ;nfhd_read_write (dev->id,0 , dir, sec >> shift, len >> shift, -bvec_to_phys (&bvec)); +page_to_phys (bvec.bv_page) + bvec.bv_offset); sec += len; }bio_endio (bio);
block/blk.h +2 -2
@@ -154,8 +154,8 @@ static inline bool biovec_phys_mergeable(struct request_queue *q, struct bio_vec *vec1, struct bio_vec *vec2) { unsigned long mask = queue_segment_boundary(q); -phys_addr_t addr1 =bvec_to_phys (vec1); -phys_addr_t addr2 =bvec_to_phys (vec2); +phys_addr_t addr1 =page_to_phys (vec1->bv_page) + vec1->bv_offset; +phys_addr_t addr2 =page_to_phys (vec2->bv_page) + vec2->bv_offset;if (addr1 + vec1->bv_len != addr2)return false;
include/linux/bio.h +0 -5
@@ -132,11 +132,6 @@ static inline bool bio_full(struct bio *bio)return bio->bi_vcnt >= bio->bi_max_vecs; } -/* -* will die -*/ -#define bvec_to_phys (bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset) -/* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it
Signature · 1 line
2.18.0
Re: [PATCH 10/13] block: remove bvec_to_phys
Quoted 5 lines · Christoph Hellwig
We only use it in
biovec_phys_mergeableand a m68k paravirt driver, so just opencode it there. Also remove the pointless unsigned long cast for the offset in the opencoded instances.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 2 lines
--- arch/m68k/emu/nfblock.c | 2 +-
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH 11/13 block: don't include io.h from bio.h
In reply to Christoph HellwigNow that we don't need an override for BIOVEC_PHYS_MERGEABLE there is no need to drag this header in.
--- include/linux/bio.h | 3 --- 1 file changed, 3 deletions(-)
include/linux/bio.h +0 -3
@@ -24,9 +24,6 @@#include <linux/bug.h> #ifdef CONFIG_BLOCK - -#include <asm/io.h> -/* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ #include <linux/blk_types.h>
Signature · 1 line
2.18.0
PATCH 12/13 block: don't include bug.h from bio.h
In reply to Christoph HellwigNo need to pull in the BUG() defintion.
--- include/linux/bio.h | 1 - 1 file changed, 1 deletion(-)
include/linux/bio.h +0 -1
@@ -21,7 +21,6 @@#include <linux/highmem.h> #include <linux/mempool.h> #include <linux/ioprio.h> -#include <linux/bug.h> #ifdef CONFIG_BLOCK /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
Signature · 1 line
2.18.0
PATCH 13/13 xen: don't include <xen/xen.h> from <asm/io.h> and <asm/dma-mapping.h>
In reply to Christoph HellwigNothing 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.18.0
Jens, any comments?
Quoted 6 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.
---end quoted text---
Jens Axboe
maintainerQuoted 11 lines · Christoph Hellwig
Jens, any comments?
Quoted 6 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits, and 13/13 should probably just to in differently.
Signature · 1 line
Jens Axboe
Quoted 9 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Quoted 1 line
and 13/13 should probably just to in differently.
I can't parse this setence.
Quoted 1 line · Christoph Hellwig
Konread, can you look at the series (or delegate).
and next time I'll spell your name correctly, sorry :)
Quoted 1 line · Christoph Hellwig
Konread, can you look at the series (or delegate).
and next time I'll spell your name correctly, sorry :)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jens Axboe
maintainerQuoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
Quoted 8 lines
Quoted 2 lines
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Quoted 1 line
and 13/13 should probably just to in differently.
I can't parse this setence.
The irony is thick :-)
Anyway, s/to/go for that sentence. I don't mind carrying it if Konrad is happy with it, but it could go in separately after this series is merged.
Signature · 1 line
Jens Axboe
Boris Ostrovsky
reviewerQuoted 11 lines · Jens Axboe
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Konrad is out this (and last) week, this looks good to me. Including patch 13, although it's hard to say whether it may break some builds.
-boris
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
and 13/13 should probably just to in differently.
I can't parse this setence.
The irony is thick :-)
Anyway, s/to/go for that sentence. I don't mind carrying it if Konrad is happy with it, but it could go in separately after this series is merged.
Quoted 2 lines · Boris Ostrovsky
Konrad is out this (and last) week, this looks good to me. Including patch 13, although it's hard to say whether it may break some builds.
I fixed up everything the buildbot reported (which was quite a bit as you can see in the patch), and the buildbot has been quiet for weeks now, so I think we should be fine.
Boris Ostrovsky
reviewerQuoted 11 lines · Jens Axboe
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Konrad is out this (and last) week, this looks good to me. Including patch 13, although it's hard to say whether it may break some builds.
-boris
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
and 13/13 should probably just to in differently.
I can't parse this setence.
The irony is thick :-)
Anyway, s/to/go for that sentence. I don't mind carrying it if Konrad is happy with it, but it could go in separately after this series is merged.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jens Axboe
maintainerQuoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
Quoted 8 lines
Quoted 2 lines
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Quoted 1 line
and 13/13 should probably just to in differently.
I can't parse this setence.
The irony is thick :-)
Anyway, s/to/go for that sentence. I don't mind carrying it if Konrad is happy with it, but it could go in separately after this series is merged.
Signature · 7 lines
Jens Axboe _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Jens Axboe
Quoted 6 lines
Quoted 4 lines
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits,
Konread, can you look at the series (or delegate).
Quoted 1 line
and 13/13 should probably just to in differently.
I can't parse this setence.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jens Axboe
maintainerQuoted 11 lines · Christoph Hellwig
Jens, any comments?
Quoted 6 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.---end quoted text---
It's a good cleanup, I like it. Would prefer if the arm/xen folks could ack the first bits, and 13/13 should probably just to in differently.
Signature · 7 lines
Jens Axboe _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Jens, any comments?
Quoted 6 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, moves the Xen special case from arch hooks into common code, cleans up the code a bit, and removes not nessecary includes from the block headers.
---end quoted text---
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel