Re: [PATCH] sd_zbc: Fix report zones buffer allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/19/19 8:48 PM, Damien Le Moal wrote:
+	/*
+	 * Limit the command buffer size to the arbitrary SD_ZBC_REPORT_SIZE
+	 * size (1MB), allowing up to 16383 zone descriptors being reported with
+	 * a single command. And make sure that this size does not exceed the
+	 * hardware capabilities. To avoid disk revalidation failures due to
+	 * memory allocation errors, retry the allocation with a smaller buffer
+	 * size if the allocation fails.
+	 */
+	bufsize = min_t(size_t, *buflen, SD_ZBC_REPORT_SIZE);
+	bufsize = min_t(size_t, bufsize,
+			queue_max_hw_sectors(disk->queue) << 9);
+	for (order = get_order(bufsize); order >= 0; order--) {
+		page = alloc_pages(gfp_mask, order);
+		if (page) {
+			*buflen = PAGE_SIZE << order;
+			return page_address(page);
+		}
+	}

Hi Damien,

As you know Linux memory fragmentation tends to increase over time. The above code has the very unfortunate property that the more memory is fragmented the smaller the allocated buffer will become. I don't think that's how kernel code should work. Have you considered to use vmalloc() + blk_rq_map_sg() instead? See also efa_vmalloc_buf_to_sg() for an example of how to build a scatterlist for memory allocated by vmalloc().

Thanks,

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux