Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751887AbdH3Ivn (ORCPT ); Wed, 30 Aug 2017 04:51:43 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:49941 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751778AbdH3Ivl (ORCPT ); Wed, 30 Aug 2017 04:51:41 -0400 Date: Wed, 30 Aug 2017 01:51:38 -0700 From: Christoph Hellwig To: Long Li Cc: Christoph Hellwig , Steve French , "linux-cifs@vger.kernel.org" , "samba-technical@lists.samba.org" , "linux-kernel@vger.kernel.org" Subject: Re: [[PATCH v1] 15/37] [CIFS] SMBD: Post a SMBD data transfer message with data payload Message-ID: <20170830085138.GA4761@infradead.org> References: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> <1501704648-20159-16-git-send-email-longli@exchange.microsoft.com> <20170813102345.GG17287@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 721 Lines: 15 On Wed, Aug 30, 2017 at 02:17:56AM +0000, Long Li wrote: > I partially addressed this issue in the V3 patch. Most of the duplicate > code on sending path is merged. > > The difficulty with translating the buffer to pages is that: I don't > know how many pages will be translated, and how many struct page I need > to allocate in advance to hold them. I try to avoid memory allocation > in the I/O path as much as possible. So I keep two functions of > sending data: one for buffer and one for pages. You do: you'll always need speace for (len + PAGE_SIZE - 1) >> PAGE_SIZE pages. That being said: what callers even send you buffers? In general we should aim to work with pages for all allocations that aren't tiny.