From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:38582 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbeJRWn2 (ORCPT ); Thu, 18 Oct 2018 18:43:28 -0400 Date: Thu, 18 Oct 2018 16:42:07 +0200 From: Christoph Hellwig To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, Vitaly Kuznetsov , Dave Chinner , Linux FS Devel , "Darrick J . Wong" , xfs@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Matthew Wilcox Subject: Re: [PATCH 4/5] block: introduce helpers for allocating IO buffers from slab Message-ID: <20181018144207.GD26828@lst.de> References: <20181018131817.11813-1-ming.lei@redhat.com> <20181018131817.11813-5-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181018131817.11813-5-ming.lei@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This all seems quite complicated. I think the interface we'd want is more one that has a little cache of a single page in the queue, and a little bitmap which sub-page size blocks of it are used. Something like (pseudo code minus locking): void *blk_alloc_sector_buffer(struct block_device *bdev, gfp_t gfp) { unsigned block_size = block_size(bdev); if (blocksize >= PAGE_SIZE) return (void *)__get_free_pages(gfp, get_order(blocksize)); if (bdev->fragment_cache_page) { [ fragment_cache_page using e.g. bitmap and return if found] } bdev->fragment_cache_page = (void *)__get_free_page(gfp); goto find_again; } note that the locking also is important, preferably we'd be able to do something lockless.