From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6849FC19F2D for ; Sat, 13 Aug 2022 13:36:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ECF88E0001; Sat, 13 Aug 2022 09:36:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4758F6B0075; Sat, 13 Aug 2022 09:36:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 315978E0001; Sat, 13 Aug 2022 09:36:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1C3726B0073 for ; Sat, 13 Aug 2022 09:36:58 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D580A404DD for ; Sat, 13 Aug 2022 13:36:57 +0000 (UTC) X-FDA: 79794670074.01.04F165C Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf21.hostedemail.com (Postfix) with ESMTP id 7CD301C007C for ; Sat, 13 Aug 2022 13:36:57 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id f22so4337013edc.7 for ; Sat, 13 Aug 2022 06:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=AKVBfO32rmZq1r8Xc6WkO9jk42SoifdEhyas0O7uhTs=; b=UdYffYR5Uny5GwXXCuOgQYee354sCFqcXWa8z7kGVw5IRH/AsBzPh3vXxLy4J9F18F +WT6wBUCx2Vtmirlt3mJ+Q2rMV2lujZ+TcoXk0LVC1fsy/JcHD8V3Yx+WVx1nWJ6cnFf 78v+kx7JV0b5Luaz5QjVH7z+PC9tYnreYMHc2flMcZvlHaYGNdv4LOnXZlCvuhM2AUhr Fl4ES1oH9dUPEdbDnf5aGteXKSb+dHbqcbPOkmfDkeTJ/kdccMspkmqU9QMBJmFZNU8W SpxOBWj7oeWuysx7qEvgQsMeolLYfFZjUq5UCJhlOjpngmGLWOHteJSwUvNUZ3lPisw3 HclQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=AKVBfO32rmZq1r8Xc6WkO9jk42SoifdEhyas0O7uhTs=; b=WA0b76juYbvJYs+zup7wppj/JAVjbwfWHPmliQb9kVlC0QZm8dp7Olub7Gz4Z8JGr6 hUrHBFljMJSTvjGRD+ZCFmAVyuDWlRKCxw9YwxEK2g1o7D4NgpvzQH38mmQtUL/MJh2c 8n0OmAHzqO8Kocf0Bu9veb3hT4MHqWES1+KDUUtSmUnv8DD7Ie2+lTuXPKBBf67V1y13 rpEKBzPVOXiMMUkVETx1SVxxPeCe1Qk8m2hGMapqv3nFLB2Xzylc2TbyMrVhuP5usMww 6JJdGJg6QJK6Q+fuKJuBaUFBNduojKDcsu1tmU22gM5JOakHh8PrUdLAO1fX3xBiUNaw cihA== X-Gm-Message-State: ACgBeo2O660D8PprfAbcYXQNZJ1ppQvCiF8m/PmD7EsgrIwnBQhWppcs 59bj7Gpg2DhAyy0Vpu6ohIk= X-Google-Smtp-Source: AA6agR6YHmhuU6n1HU6pRDZIWiUpUQGG2w90iwTEUs1ezspDX/TPu4VgLorkbgMHhQ4p/0u7Tm1uRg== X-Received: by 2002:aa7:c9c2:0:b0:440:b458:9403 with SMTP id i2-20020aa7c9c2000000b00440b4589403mr7604816edt.132.1660397816004; Sat, 13 Aug 2022 06:36:56 -0700 (PDT) Received: from opensuse.localnet (host-79-53-105-123.retail.telecomitalia.it. [79.53.105.123]) by smtp.gmail.com with ESMTPSA id w22-20020a17090633d600b0072b33e91f96sm1875765eja.190.2022.08.13.06.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 06:36:54 -0700 (PDT) From: "Fabio M. De Francesco" To: Kees Cook Cc: Alexander Viro , Eric Biederman , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny Subject: Re: [PATCH v2] fs: Replace kmap{,_atomic}() with kmap_local_page() Date: Sat, 13 Aug 2022 15:36:53 +0200 Message-ID: <8143586.NyiUUSuA9g@opensuse> In-Reply-To: <20220803182856.28246-1-fmdefrancesco@gmail.com> References: <20220803182856.28246-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660397817; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AKVBfO32rmZq1r8Xc6WkO9jk42SoifdEhyas0O7uhTs=; b=EhXJVVfxEqFxgGq9/WsLdHX+o4JLH+vxAQoSYrBc/PdSIpN35KNBs1SIetc1oKgxKJKIUp tsprg5fzQ+gZOq0baIOH9ToHY2imo5Uq2CTDgE5rwxXup3wxmRy7KnmL3+bqJyhOAT35at uVXczUyhVuPPX+v8x8glQUNZWQk9ZN8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UdYffYR5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660397817; a=rsa-sha256; cv=none; b=ivttbVj4Ph0Cn9n72htyuUBb3e7lqUSBXn0CBZYE42WBox0gHZuFCbWUb67o9MkgKXqQ79 1MhrFpxWTqqhVxYJO+BCGhZGQYl4m+5M0R40BMevXHahLvFQMxDAoBoY4T6qyyBLrhjIFr igF61ZfwRW0zat/OJaAUT3jxt+pbq6s= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7CD301C007C X-Rspam-User: X-Stat-Signature: jffsrnfp89hrtinpm7j4bu8zm5kq1uq3 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UdYffYR5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of fmdefrancesco@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=fmdefrancesco@gmail.com X-HE-Tag: 1660397817-486700 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On mercoled=C3=AC 3 agosto 2022 20:28:56 CEST Fabio M. De Francesco wrote: > The use of kmap() and kmap_atomic() are being deprecated in favor of > kmap_local_page(). >=20 > There are two main problems with kmap(): (1) It comes with an overhead as > mapping space is restricted and protected by a global lock for > synchronization and (2) it also requires global TLB invalidation when the > kmap=E2=80=99s pool wraps and it might block when the mapping space is fu= lly > utilized until a slot becomes available. >=20 > With kmap_local_page() the mappings are per thread, CPU local, can take > page faults, and can be called from any context (including interrupts). > It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, > the tasks can be preempted and, when they are scheduled to run again, the > kernel virtual addresses are restored and are still valid. >=20 > Since the use of kmap_local_page() in exec.c is safe, it should be > preferred everywhere in exec.c. >=20 > As said, since kmap_local_page() can be also called from atomic context, > and since remove_arg_zero() doesn't (and shouldn't ever) rely on an > implicit preempt_disable(), this function can also safely replace > kmap_atomic(). >=20 > Therefore, replace kmap() and kmap_atomic() with kmap_local_page() in > fs/exec.c. >=20 > Tested with xfstests on a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel > with HIGHMEM64GB enabled. >=20 > Cc: Eric W. Biederman > Suggested-by: Ira Weiny > Reviewed-by: Ira Weiny > Signed-off-by: Fabio M. De Francesco > --- >=20 > v1->v2: Added more information to the commit log to address some > objections expressed by Eric W. Biederman[1] in reply to v1. No changes > have been made to the code. Forwarded a tag from Ira Weiny (thanks!). >=20 > [1] > https://lore.kernel.org/lkml/8735fmqcfz.fsf@email.froward.int.ebiederm.or= g/ > > fs/exec.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) >=20 Hi Kees, After that thread about the report from Syzbot, and the subsequent discussi= on,=20 I noticed that you didn't yet take this other patch for exec.c. I suppose that the two patches would better go out together. So I'm writing= =20 for sending a gentle ping. As I said, no changes have been made to the code with respect to v1 (which = I=20 submitted in June). However, later I thought that adding more information=20 might have helped reviewers and maintainers to better understand the why of= =20 this patch. Thanks, =46abio =20