Message ID | 20221231174205.8492-1-fmdefrancesco@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3444664wrt; Sat, 31 Dec 2022 09:48:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvTBOWO3GJdQqtqV0RxSJmbtASlkkTK8DiLtl2Jn1LXvQwvjzhkU6M3VbFCKc62AdbSbLi/ X-Received: by 2002:a17:906:158c:b0:7c4:f752:e959 with SMTP id k12-20020a170906158c00b007c4f752e959mr28826955ejd.33.1672508938116; Sat, 31 Dec 2022 09:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672508938; cv=none; d=google.com; s=arc-20160816; b=D7KV6YUkPgilzncgz22MGA965nQnvJJuveiOBaK+6N1wlmg56oT3SvB10aAUoSHD+n 4X5e/AGKwbS0MpK0b7DbvgmoIXfXu70cdOUGom121Au7YdKhlkrwB/qUnlYR6qRVAK/x TNrCNzLboJWzH9SgCk3Jf/eJck1ALaYwghLpm0gr+XUQFO+2od62cnwmPi6nLy6e8HEH vkaTi4BMGHg6NhVl06ltW2G42ULbZkAT6jwfZ+tbCnlAlTm4PWJo2UdtzdX1jz++OIBF RYnEDaUZoiLDUtVxzr8cPr4qBi38nd5AnyRCzUjMIXQqeq05m6t6hHUsD43cKtkQclNg PznQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=VDxzoBipuwgJ9nXmM8IIPQyqkbvF/xMtt7DwxtCT5D8=; b=AnijBmWXE2GApNlLAK5HDf0EZ2t+Qldbi8/N2Jvo+O3N+C9iNRZ5PPm4i1NJnoEsNu lcafqUy4ZbUrOqnzQ4gWFvqzClknTyqgLeRMqSkWl0hI8fX8lVXWTY0cpub2HW9DUSTW tIA46Z0Vi9XBhoF32mSn5Msun1kOs9ImPn1Z8XW4xQX/SqVRgzSmO0eKpWRkGcjv1e6Y BXbfGfAXhvnzEsz46pVLT1wMEbZI7II7Cbo5C2LO1zqcQnxflJ27jOShkD6YStwk1fLe BsCd3ol1SigWSRfGx0GpMBeomf3q2ocOZ8wCss2MCpE9ZVdSx6EbVGfhJnzp+kjE8VUX M6hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pBKkIKny; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn8-20020a17090794c800b007c1b8be370bsi22553620ejc.710.2022.12.31.09.48.34; Sat, 31 Dec 2022 09:48:58 -0800 (PST) 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=pass header.i=@gmail.com header.s=20210112 header.b=pBKkIKny; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbiLaRmP (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Sat, 31 Dec 2022 12:42:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLaRmN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 31 Dec 2022 12:42:13 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0851CF52; Sat, 31 Dec 2022 09:42:12 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so20976439wma.1; Sat, 31 Dec 2022 09:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VDxzoBipuwgJ9nXmM8IIPQyqkbvF/xMtt7DwxtCT5D8=; b=pBKkIKnyLK8+/jEPZDupGUVaRyZrdOvlC2089EskdKymkUwbjENKm+zuo8Pldcfb53 zm2DVZjMwulgcyUrlgkoIfVSVnolqaWfE1We1P8mk7guvoWifd+1otzRUXghhWu6eQkq O6VFCIwEwe9FS0fwxmAg2F73QY7mMgxTiD9zqItf1ellgexmGsKeXAqxEyx1jZ0yHOwG Z4w+i663b/hCn2reqN3dWZCXO6khUNEdsO0qnOlWAGRUZH6j1pyRFbtulgMByMdfHQoM PHVU8Rlzhj6d5D2gXdArBnS/7aAZBWi/KM6FkuAPutCxVW4tqbLVM6BVw1fg4H8D4YO3 q90A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VDxzoBipuwgJ9nXmM8IIPQyqkbvF/xMtt7DwxtCT5D8=; b=5iKaP4Z7bfI20ia5UpbGHVq6wu1qVk9FshKtRNBqxsQzqf/vN37xnu2a2mtubCAfmE /ifuv6u4V8gJ4SiII6ZCC35AuQeSES180EDZpJMElY/xklH/K8RqxQOvaUFb3kBK7yI3 adkMtGOz5U4XxH6s4R0h8SlWfU55RKk14nFug+frZ1uWpdAdAlNh9OB22yyaRfn+ILSk 2EuWJCSXmP6G86wAVOBNWGUhbdWo2uJElRuszqLQEF57NSDa9OqJlWP/2IpgZnKhDn+y TMhec1m+JyPRsKGNN5VbtbXuSlTDyzY0QNeeDKPj3asd0NO3aGMUMH0N8u+7tC7+yfnO rQ9Q== X-Gm-Message-State: AFqh2kpwrzAs7kJCKDXIPtuNCRUVCwbKCqfqoKuvsn4D1QwEw3Bm3vx1 YUpMN5VIZpOzy7lJGLksgMM= X-Received: by 2002:a05:600c:1c90:b0:3cf:75a8:ecf4 with SMTP id k16-20020a05600c1c9000b003cf75a8ecf4mr25553418wms.24.1672508530472; Sat, 31 Dec 2022 09:42:10 -0800 (PST) Received: from localhost.localdomain (host-79-56-217-20.retail.telecomitalia.it. [79.56.217.20]) by smtp.gmail.com with ESMTPSA id bi14-20020a05600c3d8e00b003d9ad6783b1sm2032817wmb.6.2022.12.31.09.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Dec 2022 09:42:09 -0800 (PST) From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com> To: Jan Kara <jack@suse.com>, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>, Ira Weiny <ira.weiny@intel.com> Subject: [PATCH] fs/ext2: Replace kmap_atomic() with kmap_local_page() Date: Sat, 31 Dec 2022 18:42:05 +0100 Message-Id: <20221231174205.8492-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1753752731926725584?= X-GMAIL-MSGID: =?utf-8?q?1753752731926725584?= |
Series |
fs/ext2: Replace kmap_atomic() with kmap_local_page()
|
|
Commit Message
Fabio M. De Francesco
Dec. 31, 2022, 5:42 p.m. UTC
kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore,
replace kmap_atomic() with kmap_local_page().
kmap_atomic() is implemented like a kmap_local_page() which also disables
page-faults and preemption (the latter only for !PREEMPT_RT kernels).
However, the code within the mapping and un-mapping in ext2_make_empty()
does not depend on the above-mentioned side effects.
Therefore, a mere replacement of the old API with the new one is all it
is required (i.e., there is no need to explicitly add any calls to
pagefault_disable() and/or preempt_disable()).
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
I tried my best to understand the code within mapping and un-mapping.
However, I'm not an expert. Therefore, although I'm pretty confident, I
cannot be 100% sure that the code between the mapping and the un-mapping
does not depend on pagefault_disable() and/or preempt_disable().
Unfortunately, I cannot currently test this changes to check the
above-mentioned assumptions. However, if I'm required to do the tests
with (x)fstests, I have no problems with doing them in the next days.
If so, I'll test in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
HIGHMEM64GB enabled.
I'd like to hear whether or not the maintainers require these tests
and/or other tests.
fs/ext2/dir.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Sat 31-12-22 18:42:05, Fabio M. De Francesco wrote: > kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, > replace kmap_atomic() with kmap_local_page(). > > kmap_atomic() is implemented like a kmap_local_page() which also disables > page-faults and preemption (the latter only for !PREEMPT_RT kernels). > > However, the code within the mapping and un-mapping in ext2_make_empty() > does not depend on the above-mentioned side effects. > > Therefore, a mere replacement of the old API with the new one is all it > is required (i.e., there is no need to explicitly add any calls to > pagefault_disable() and/or preempt_disable()). > > Suggested-by: Ira Weiny <ira.weiny@intel.com> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Thanks, the patch looks good and I'll queue it in my tree. I'm not sure why it got missed during the initial conversion by Ira :). Honza > --- > > I tried my best to understand the code within mapping and un-mapping. > However, I'm not an expert. Therefore, although I'm pretty confident, I > cannot be 100% sure that the code between the mapping and the un-mapping > does not depend on pagefault_disable() and/or preempt_disable(). > > Unfortunately, I cannot currently test this changes to check the > above-mentioned assumptions. However, if I'm required to do the tests > with (x)fstests, I have no problems with doing them in the next days. > > If so, I'll test in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with > HIGHMEM64GB enabled. > > I'd like to hear whether or not the maintainers require these tests > and/or other tests. > > fs/ext2/dir.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c > index e5cbc27ba459..0f144c5c7861 100644 > --- a/fs/ext2/dir.c > +++ b/fs/ext2/dir.c > @@ -646,7 +646,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) > unlock_page(page); > goto fail; > } > - kaddr = kmap_atomic(page); > + kaddr = kmap_local_page(page); > memset(kaddr, 0, chunk_size); > de = (struct ext2_dir_entry_2 *)kaddr; > de->name_len = 1; > @@ -661,7 +661,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) > de->inode = cpu_to_le32(parent->i_ino); > memcpy (de->name, "..\0", 4); > ext2_set_de_type (de, inode); > - kunmap_atomic(kaddr); > + kunmap_local(kaddr); > ext2_commit_chunk(page, 0, chunk_size); > err = ext2_handle_dirsync(inode); > fail: > -- > 2.39.0 >
On Mon, Jan 02, 2023 at 01:34:11PM +0100, Jan Kara wrote: > On Sat 31-12-22 18:42:05, Fabio M. De Francesco wrote: > > kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore, > > replace kmap_atomic() with kmap_local_page(). > > > > kmap_atomic() is implemented like a kmap_local_page() which also disables > > page-faults and preemption (the latter only for !PREEMPT_RT kernels). > > > > However, the code within the mapping and un-mapping in ext2_make_empty() > > does not depend on the above-mentioned side effects. > > > > Therefore, a mere replacement of the old API with the new one is all it > > is required (i.e., there is no need to explicitly add any calls to > > pagefault_disable() and/or preempt_disable()). > > > > Suggested-by: Ira Weiny <ira.weiny@intel.com> > > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> > > Thanks, the patch looks good and I'll queue it in my tree. I'm not sure why > it got missed during the initial conversion by Ira :). > I could claim something smart like I was focused on kmap() calls only. But let's just call it laziness. ;-) LGTM Reviewed-by: Ira Weiny <ira.weiny@intel.com> > Honza > > > > --- > > > > I tried my best to understand the code within mapping and un-mapping. > > However, I'm not an expert. Therefore, although I'm pretty confident, I > > cannot be 100% sure that the code between the mapping and the un-mapping > > does not depend on pagefault_disable() and/or preempt_disable(). > > > > Unfortunately, I cannot currently test this changes to check the > > above-mentioned assumptions. However, if I'm required to do the tests > > with (x)fstests, I have no problems with doing them in the next days. > > > > If so, I'll test in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with > > HIGHMEM64GB enabled. > > > > I'd like to hear whether or not the maintainers require these tests > > and/or other tests. > > > > fs/ext2/dir.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c > > index e5cbc27ba459..0f144c5c7861 100644 > > --- a/fs/ext2/dir.c > > +++ b/fs/ext2/dir.c > > @@ -646,7 +646,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) > > unlock_page(page); > > goto fail; > > } > > - kaddr = kmap_atomic(page); > > + kaddr = kmap_local_page(page); > > memset(kaddr, 0, chunk_size); > > de = (struct ext2_dir_entry_2 *)kaddr; > > de->name_len = 1; > > @@ -661,7 +661,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) > > de->inode = cpu_to_le32(parent->i_ino); > > memcpy (de->name, "..\0", 4); > > ext2_set_de_type (de, inode); > > - kunmap_atomic(kaddr); > > + kunmap_local(kaddr); > > ext2_commit_chunk(page, 0, chunk_size); > > err = ext2_handle_dirsync(inode); > > fail: > > -- > > 2.39.0 > > > -- > Jan Kara <jack@suse.com> > SUSE Labs, CR
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index e5cbc27ba459..0f144c5c7861 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -646,7 +646,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) unlock_page(page); goto fail; } - kaddr = kmap_atomic(page); + kaddr = kmap_local_page(page); memset(kaddr, 0, chunk_size); de = (struct ext2_dir_entry_2 *)kaddr; de->name_len = 1; @@ -661,7 +661,7 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) de->inode = cpu_to_le32(parent->i_ino); memcpy (de->name, "..\0", 4); ext2_set_de_type (de, inode); - kunmap_atomic(kaddr); + kunmap_local(kaddr); ext2_commit_chunk(page, 0, chunk_size); err = ext2_handle_dirsync(inode); fail: