Message ID | 4d132d7aa9cc71f88e6e02c8f6fcb0fec56542aa.1688073459.git.drv@mailo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9944283vqr; Thu, 29 Jun 2023 15:11:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFgvTRGP5dv3L0EFJiaNA8DgYmBifzmmj1VzwBH2uq9dtMTwDNAC/GChygL7xGk0spt7RO+ X-Received: by 2002:a05:6e02:164c:b0:340:ae63:38a4 with SMTP id v12-20020a056e02164c00b00340ae6338a4mr549238ilu.2.1688076713878; Thu, 29 Jun 2023 15:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688076713; cv=none; d=google.com; s=arc-20160816; b=fQqImOi6yIE9bwM624/TXtT3vdBXN1qYyHbPsL98JDxdnotmOaH7bVcHvotjtHmU6M JN4at2iE888SyannbF8UXLC5lbCYkvOh6RtgMBKlX5Jr8hSSgbVgZ21uXh8ndXM+KEsZ aRuHkGObOMI6FdfRVavm6h9xPNxTm676HZ+hAoIwAvE99wu37WF5XDjHTMQoad3Mvd/G lNeazS3qBPlwqi8GythSUWElUpe1nAlplKzRyYqPeXQNZ5svAqTHOGshY2IzTNoX4UEE IaszE757BAPEiZonnoHMQ4Sl/+rLV5W6st9ebY1EEPviCYI3z0vh0Q+9LeQaQfrV2yhW sDsQ== 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=UpLlHUWZXL87rYGugpIj04FqgAB+oKEsvUu+Ka67nCE=; fh=2/OepbD16sII06AHmQTJgD7xcw2OMNoUEY9t7KuTeGw=; b=gQ+vitCxOma0o7GwHQ5UsZTwGUoW6JfypihYMNRDM5c976uXAOZnBs/mCU9/Gvju7w h4sA9EFuoeRzMWiTEM+lAtwEtqGbd0QrYHea9mY2Y5Hr8XjyAXKELEjpSs2KKoJYagqN Wkc2fXe2MEn340lPRfMefqyS4d22mhORizcCSehjiN16tN8w5EL3QFKrW3AdD/ZDBsh0 sCbo6t1ZOx8IZWA3gRGZO1v1XlCnBkHqIE3R8Z/367k6MYSqpW5kS7py2LIWyK05Fj2l lI8JNTwGkSv/tRCRxZ399x0/DEsDKwaurNGaqokxwlR8CoYyGVAU92RTtFRNTm8xxG4x c0ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Y2Y80Hzd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j192-20020a638bc9000000b00542b1792242si11322780pge.720.2023.06.29.15.11.39; Thu, 29 Jun 2023 15:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Y2Y80Hzd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjF2VuY (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 17:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbjF2VuW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 17:50:22 -0400 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C2530EC for <linux-kernel@vger.kernel.org>; Thu, 29 Jun 2023 14:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1688075416; bh=x7zd5uVxyeDRl54E+RTPj06ix1hRuqdAnUwSzOvgF+8=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=Y2Y80HzdbqBIq3756vJTl6ufeFaY0ZCXI1TkJovWlAK94g55+ZynJfooM/S2vE0zN 92Vlg8l+PHyjD89HEQTr1ND9SWZ+EOPuE6vWrLzfdn4IAPpjOBZSbQIYie4KZcR1Yy qL/OG7LlBUiH5LmWx6bWQoIAXmMPIMio5T9yu7JE= Received: by b221-3.in.mailobj.net [192.168.90.23] with ESMTP via ip-20.mailobj.net [213.182.54.20] Thu, 29 Jun 2023 23:50:16 +0200 (CEST) X-EA-Auth: 8qhRdke3mHv05h5eyYsrMODcCW4Qllf4hyhJ119mGTYvfLGar6Bbd79n7KIGsdADT98DNArOr+XjY8Xfvucm8mUPvSIQ7zbX Date: Fri, 30 Jun 2023 03:20:07 +0530 From: Deepak R Varma <drv@mailo.com> To: Bob Peterson <rpeterso@redhat.com>, Andreas Gruenbacher <agruenba@redhat.com>, cluster-devel@redhat.com, linux-kernel@vger.kernel.org Cc: Ira Weiny <ira.weiny@intel.com>, "Fabio M. De Francesco" <fmdefrancesco@gmail.com>, Sumitra Sharma <sumitraartsy@gmail.com>, Deepak R Varma <drv@mailo.com> Subject: [PATCH v3 2/6] gfs2: Replace kmap_atomic()+memcpy by memcpy_from_page() Message-ID: <4d132d7aa9cc71f88e6e02c8f6fcb0fec56542aa.1688073459.git.drv@mailo.com> References: <cover.1688073459.git.drv@mailo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <cover.1688073459.git.drv@mailo.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770076728219159616?= X-GMAIL-MSGID: =?utf-8?q?1770076728219159616?= |
Series |
gfs2: kmap{_atomic} conversion to kmap_local_{page/folio}
|
|
Commit Message
Deepak R Varma
June 29, 2023, 9:50 p.m. UTC
kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().
kmap_atomic() disables page-faults and preemption (the latter only for
!PREEMPT_RT kernels), However, the code within the mapping/un-mapping in
gfs2_internal_read() does not depend on the above-mentioned side effects.
Further, memcpy_{from,to}_page() wrappers combine the
{kmap, unmap}_local_page() blocks when they are intended exclusively to
copy contents from/to the temporary mapped page. So, replace the
kmap_atomic()/kunmap_automic() block by the memcpy_from_page() API call.
This change allows to tidy-up code and also eliminate unused variable p.
Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Changes in v3:
- Split as a separate patch for conversion in gfs2_internal_read()
- Use memcpy_from_page() as suggested by Fabio and Andreas G
- Included split version in patch set
Changes in v2:
- Update patch description to correct the replacement function name
from kmap_local_folio to kmap_local _page
fs/gfs2/aops.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Comments
On giovedì 29 giugno 2023 23:50:07 CEST Deepak R Varma wrote: > kmap_atomic() is deprecated in favor of kmap_local_{folio,page}(). > > kmap_atomic() disables page-faults and preemption (the latter only for > !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in > gfs2_internal_read() does not depend on the above-mentioned side effects. > > Further, memcpy_{from,to}_page() wrappers combine the > {kmap, unmap}_local_page() blocks when they are intended exclusively to > copy contents from/to the temporary mapped page. So, replace the > kmap_atomic()/kunmap_automic() s/kunmap_automic/kunmap_atomic/ > block by the memcpy_from_page() API call. > This change allows to tidy-up code and also eliminate unused variable p. > > Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> I don't like to read the list of the functions replaced by the memcpy_from_page() helper in the subject of the patch. These details are better suited in commit messages. Furthermore, you have not been consistent: "kmap_atomic()+memcpy" contains parentheses only in one of the two functions. Both or none. The thing that really matters here is that You are replacing the deprecated kmap_atomic() with kmap_local_page(). This is what the subject should show. Please cite the use of the suited helper _only_ within the commit message and explain why it is preferred to open code kmap_local_page() + memcpy() + kunmap_local(). > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > Changes in v3: > - Split as a separate patch for conversion in gfs2_internal_read() > - Use memcpy_from_page() as suggested by Fabio and Andreas G > - Included split version in patch set > > Changes in v2: > - Update patch description to correct the replacement function name > from kmap_local_folio to kmap_local _page > > > > fs/gfs2/aops.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c > index 3eac4f2f5c27..f47fed657763 100644 > --- a/fs/gfs2/aops.c > +++ b/fs/gfs2/aops.c > @@ -489,7 +489,6 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, > loff_t *pos, unsigned copied = 0; > unsigned amt; > struct page *page; > - void *p; > > do { > page = read_cache_page(mapping, index, gfs2_read_folio, NULL); > @@ -498,12 +497,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, > loff_t *pos, continue; > return PTR_ERR(page); > } > - p = kmap_atomic(page); > - amt = size - copied; > if (offset + size > PAGE_SIZE) > amt = PAGE_SIZE - offset; > - memcpy(buf + copied, p + offset, amt); > - kunmap_atomic(p); > + else > + amt = size - copied; This is a different logical change. Please put it in a different patch with proper subject and commit message. Thanks, Fabio > + > + memcpy_from_page(buf, page, offset, amt); > put_page(page); > copied += amt; > index++; > -- > 2.34.1
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 3eac4f2f5c27..f47fed657763 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -489,7 +489,6 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, unsigned copied = 0; unsigned amt; struct page *page; - void *p; do { page = read_cache_page(mapping, index, gfs2_read_folio, NULL); @@ -498,12 +497,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, continue; return PTR_ERR(page); } - p = kmap_atomic(page); - amt = size - copied; if (offset + size > PAGE_SIZE) amt = PAGE_SIZE - offset; - memcpy(buf + copied, p + offset, amt); - kunmap_atomic(p); + else + amt = size - copied; + + memcpy_from_page(buf, page, offset, amt); put_page(page); copied += amt; index++;