On Fri, Jan 10, 2020 at 02:37:44PM +0800, Ming Lei wrote: > On Thu, Jan 09, 2020 at 09:10:24PM -0800, Guenter Roeck wrote: > > On 1/9/20 7:00 PM, Ming Lei wrote: > > > On Fri, Jan 10, 2020 at 10:58:01AM +0800, Ming Lei wrote: > > > > On Thu, Jan 09, 2020 at 08:18:04AM -0700, Jens Axboe wrote: > > > > > On 1/9/20 12:16 AM, Christoph Hellwig wrote: > > > > > > On Thu, Jan 09, 2020 at 10:03:41AM +0800, Ming Lei wrote: > > > > > > > It has been addressed in: > > > > > > > > > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=block-5.5&id=ecd255974caa45901d0b8fab03626e0a18fbc81a > > > > > > > > > > > > That is probably correct, but still highly suboptimal for most 32-bit > > > > > > architectures where physical addresses are 32 bits wide. To fix that > > > > > > the proper phys_addr_t type should be used. > > > > > > > > > > I'll swap it for phys_addr_t - we used to use dma_address_t or something > > > > > like that, but I missed this type. > > > > > > > > Guenter mentioned that 'page_to_phys(start_page) as well as offset are > > > > sometimes 0'[1]. > > > > > > > > If that(zero page physical address) can happen when phys_addr_t is 32bit, > > > > I guess phys_addr_t may not work too. > > > > > > > > Guener, could you test the patch in link[2] again? > > > > > > > > > > > > [1] https://lore.kernel.org/linux-block/20200108023822.GB28075@ming.t460p/T/#m5862216b960454fc41a85204defbb887983bfd75 > > > > [2] https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=block-5.5&id=b6a89c4a9590663f80486662fe9a9c1f4cee31f4 > > > > > > Loop Guener in. > > > > > > > The patch at [2] doesn't work. > > > > My understanding is that the page in question is not mapped when > > get_max_segment_size() is called (after all, the operation is the > > result of a page fault). This is why page_to_phys() returns 0. > > page_to_phys() supposes to return page's physical address, which > should just depend on this machine's physical address space, > not related with page mapping. > > I understand physical address 0 might be valid, such as the 1st > page frame of ram. > > > > > You'll either need a local u64 variable, or use some other means > > to handle that situation. Something like > > > > phys_addr_t paddr = page_to_phys(start_page); > > > > if (paddr == 0) > > return queue_max_segment_size(q); > > > > at the beginning of the function might do, though there might > > still be a problem when the page is later assigned and crosses > > a segment boundary (if that is possible). > > IMO, zero physical address case is the only corner case not > covered by using 'phys_addr_t'. If phys_addr_t is 32bit, sum of > page_to_phys(start_page) and offset shouldn't be >= 4G. Or could you test the following patch? diff --git a/block/blk-merge.c b/block/blk-merge.c index 347782a24a35..d1bed8c382bf 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -164,8 +164,13 @@ static inline unsigned get_max_segment_size(const struct request_queue *q, unsigned long mask = queue_segment_boundary(q); offset = mask & (page_to_phys(start_page) + offset); - return min_t(unsigned long, mask - offset + 1, - queue_max_segment_size(q)); + + /* + * overflow may be triggered in case of zero page physical address + * on 32bit arch, use queue's max segment size when that happens + */ + return min_not_zero(mask - offset + 1, + (unsigned long)queue_max_segment_size(q)); } /** Thanks, Ming