Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5726917pxv; Wed, 21 Jul 2021 12:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1RSj10ew5GWcwcmTuc6j17nfy8JFdvv9TRJ6L2owOX3pjIBw2/xISJ9RVs8XVJdRIKtKo X-Received: by 2002:a05:6638:39c2:: with SMTP id o2mr31695643jav.87.1626895465814; Wed, 21 Jul 2021 12:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626895465; cv=none; d=google.com; s=arc-20160816; b=L2/hLIjIl6/dtJdEhvRZsOr3R0inO5cNarKYdzvmQQKmbq4rLCWopQP7kI5+h9/8QV tSgKa6YeBGQdRZQ4MZ/GJHLSJ/avhpaJeHzQWpgf0ti2YVj9AitNQlOH1ZMsi9hIYfif /598AIW4GxPUin6gdfg7K+sMJB5x/WI1ox8kmoP9oBIteKKHF0gU/dxLk4kXGJZ6zMno 3CXIQAzxoBi4HPVGTvvt2YgWi2r0pDUua5OXJVwy6+QVw7ulbu6kqAR8Dfx8kIBdCzhY c2VfAUBWbdeLdpZSj+C1G3jPMWosxI6N0Yhrdsd+HeBwsazUA7T31cI/lXtLmo5NXIzg KCng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=h7ANzi28cJoXw5bIQRlhcc2oIPfOzsiQY9b/sjNzY2k=; b=qUODIYhVK4EcCFs7l1npUkvunUwl1eoirR1w/qn4FZ9nacXkKwZfnRmI6yS4miQaNn Xm+l9IU3+kSaYAZrGUBIWtqkKFtduvEPhO83DN4voGoSM8MncWhwxvR6Btdu7x0zR3IU 4FuHEUZnWPzPtOzyL4gpbZaXlR5fe82oqk7Ter3UWfMm2gFYFsp9/vo4dHogJJ565ipg kabatL8vghMuCj90Eige7k48aWV6WM2VRrctO3X6wN0uOis2Y4uCZzrK6gfVzQ2VdRuL o982qHSQNN5pGFcAlx8TdrmULw9KYfDOg81Cfmd323kqdOGa0WS/CYQOBwW9lHOif4kw 76hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SWdacA+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si33884818ilu.63.2021.07.21.12.24.14; Wed, 21 Jul 2021 12:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SWdacA+s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238621AbhGUNpx (ORCPT + 99 others); Wed, 21 Jul 2021 09:45:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:41242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239491AbhGUNmb (ORCPT ); Wed, 21 Jul 2021 09:42:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B0EA66121F; Wed, 21 Jul 2021 14:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626877343; bh=4NTnFEe2l3CAr2NuivBsayg3RBvIVlGjYGI9vT1IRx0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SWdacA+swjElFXK4xDg7Y5+tnh9JLsd2jeuI09FuvMfY7Uu72LwA9IBdw95kknr96 Ob+ppAo/jhfJ9SSpZYKmpufBNfj1ZTdWC19ww9ZjZI78ry7I82EQUDvWdl8TNtUrg9 KNcNhqlzqpNxhJsTOa3KTSnEWdUpe/Zf/HjqHbr7/kEFphV2T+3BB+MA1G+uUXvCLR Kyj1pDCgsSnybQHtv/jdu6dlmbck0jxtFrYQFUJcVNG2HcfDNblVz8TsTAtoBJHDBr 5xFkROedkpIiHYC7h/TKPww3Jl87DCb1jMPhw8nG3mDCRGxyxPoAu9M4VyUxvp+Vzg yn6Uy2lXL/wuQ== Date: Wed, 21 Jul 2021 17:22:16 +0300 From: Mike Rapoport To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v14 054/138] mm: Add kmap_local_folio() Message-ID: References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-55-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 03:12:03PM +0100, Matthew Wilcox wrote: > On Wed, Jul 21, 2021 at 12:58:24PM +0300, Mike Rapoport wrote: > > > +/** > > > + * kmap_local_folio - Map a page in this folio for temporary usage > > > + * @folio: The folio to be mapped. > > > + * @offset: The byte offset within the folio. > > > + * > > > + * Returns: The virtual address of the mapping > > > + * > > > + * Can be invoked from any context. > > > > Context: Can be invoked from any context. > > > > > + * > > > + * Requires careful handling when nesting multiple mappings because the map > > > + * management is stack based. The unmap has to be in the reverse order of > > > + * the map operation: > > > + * > > > + * addr1 = kmap_local_folio(page1, offset1); > > > + * addr2 = kmap_local_folio(page2, offset2); > > > > Please s/page/folio/g here and in the description below > > > > > + * ... > > > + * kunmap_local(addr2); > > > + * kunmap_local(addr1); > > > + * > > > + * Unmapping addr1 before addr2 is invalid and causes malfunction. > > > + * > > > + * Contrary to kmap() mappings the mapping is only valid in the context of > > > + * the caller and cannot be handed to other contexts. > > > + * > > > + * On CONFIG_HIGHMEM=n kernels and for low memory pages this returns the > > > + * virtual address of the direct mapping. Only real highmem pages are > > > + * temporarily mapped. > > > + * > > > + * While it is significantly faster than kmap() for the higmem case it > > > + * comes with restrictions about the pointer validity. Only use when really > > > + * necessary. > > > + * > > > + * On HIGHMEM enabled systems mapping a highmem page has the side effect of > > > + * disabling migration in order to keep the virtual address stable across > > > + * preemption. No caller of kmap_local_folio() can rely on this side effect. > > > + */ > > kmap_local_folio() only maps one page from the folio. So it's not > appropriate to s/page/folio/g. I fiddled with the description a bit to > make this clearer: > > /** > * kmap_local_folio - Map a page in this folio for temporary usage > - * @folio: The folio to be mapped. > - * @offset: The byte offset within the folio. > - * > - * Returns: The virtual address of the mapping > - * > - * Can be invoked from any context. > + * @folio: The folio containing the page. > + * @offset: The byte offset within the folio which identifies the page. > * > * Requires careful handling when nesting multiple mappings because the map > * management is stack based. The unmap has to be in the reverse order of > * the map operation: > * > - * addr1 = kmap_local_folio(page1, offset1); > - * addr2 = kmap_local_folio(page2, offset2); > + * addr1 = kmap_local_folio(folio1, offset1); > + * addr2 = kmap_local_folio(folio2, offset2); > * ... > * kunmap_local(addr2); > * kunmap_local(addr1); > @@ -131,6 +127,9 @@ static inline void *kmap_local_page(struct page *page); > * On HIGHMEM enabled systems mapping a highmem page has the side effect of > * disabling migration in order to keep the virtual address stable across > * preemption. No caller of kmap_local_folio() can rely on this side effect. > + * > + * Context: Can be invoked from any context. > + * Return: The virtual address of @offset. > */ > static inline void *kmap_local_folio(struct folio *folio, size_t offset) This is clearer, thanks! Maybe just add page to Return: description: * Return: The virtual address of page @offset. -- Sincerely yours, Mike.