From patchwork Mon Aug 21 17:39:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13359699 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 ECCDAEE49A5 for ; Mon, 21 Aug 2023 17:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43E6A8E0012; Mon, 21 Aug 2023 13:39:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EE7D8E0010; Mon, 21 Aug 2023 13:39:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B6618E0012; Mon, 21 Aug 2023 13:39:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 18B3E8E0010 for ; Mon, 21 Aug 2023 13:39:35 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E239A40CDD for ; Mon, 21 Aug 2023 17:39:34 +0000 (UTC) X-FDA: 81148823868.12.2110E2E Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf30.hostedemail.com (Postfix) with ESMTP id 2FC5680006 for ; Mon, 21 Aug 2023 17:39:32 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=h3oLSE0M; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692639572; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MJX7MwjsOoEAU4n1K0Gc7OUpchcxhrveli2zRquYcfM=; b=GcLxCNsced3riG5OTUonnI8dEfPwhdR3juE1lJbeYD2k3t0/EXq+mgdvo4aoeiFvHriAhZ eQFOL4ZHOO+ve3HKxomg2HD/teFS/TYg724ZSp3aebeA1I7SKL5+nMXpG94IGw6r+OPkBL XQPGWA3l6w2ukwOyZkQIBcQnX2qUIlo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=h3oLSE0M; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692639572; a=rsa-sha256; cv=none; b=BiGPnWBCtlj8ON3pdpAeVjRsCCmk3JoKsPyj8S304AYrwRFyLvP8tTe/MHwMLlGiSLpBip o84M/evs3g1QCUNbOmQpmLVpyc0NofrJH4vJAEKWsS9uVAPZfyyYJs6SxyWCfFhs4jJzRu nxA9/sgyZaYdthHAoiCbqcpbuQ98F68= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-58fb8963617so25814557b3.3 for ; Mon, 21 Aug 2023 10:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692639571; x=1693244371; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=MJX7MwjsOoEAU4n1K0Gc7OUpchcxhrveli2zRquYcfM=; b=h3oLSE0MPb0Y6Ruphc34mC5EejRltyhCWY0ARZy+OddyslyW4KueR8NGvHkw/fNU/O LO7GxPGuKSA5HlxAmMJ7PZkhIGPe/N8dhTWw+siswnce5O95prajQi19L19IhtR9jopE MNHTPKqBNzrlFq1fnOvnuSDECn9pTNgwKidiqLJzWtATH6XEovc0+T5uWLSgVvNKZAwf gngmJvzGPWuFSXwKkzbZXv70/XSxjLdqMOTgQOTzc5jWW1xaqHotoKHMqr2DdJ2GZrDz lyV9HljFHW6Zs556nBEkP0bIBssLD3g40i1bgMYur00mmBdbqw68ULwOVxHEY3Ia0Jdy 6abg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692639571; x=1693244371; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MJX7MwjsOoEAU4n1K0Gc7OUpchcxhrveli2zRquYcfM=; b=M7eqAZ0gbHl8O6Tdp4BfwsHxMIg1oEkKf4o3RMmxUSOfSZf5UXeUHOQiIy3oUR4VV5 sqCJnt6hik7Q/8uCJTxaJ1YFxhGGCQBgfpU5cR+PtwbkpGQ4R3xhAZeOe8r+M1wO4wCI rgleak+/6m6LIyPHFWKOk7He5FIk8sgjag18i/ubI4x/4pSWwta3uFS7yknksFCuYn1p 2yPWa7PCgHDx4V124VibD4IWH/Zvin7Er9HAbXmZj3Agq9Ky5qQXsosiX7RFI3aWDN2S B6ggI6OXh+nAMQf5ChSdGT/9GjxBSF0OB/Oqdv+uG1rR9N0XMaP3epOh8A2xTkkNMrXJ 03Dw== X-Gm-Message-State: AOJu0YyZs018iN6rX/Fj35r//9T/fmqJcjkNa4a48SuT59R0/6ps0oEk 8zxLaMJ2Nu1jSmLzfaJpGC9yeQ== X-Google-Smtp-Source: AGHT+IETtLD2S7L2QNNi7uG8/ZS7v+I1kKPcz+3JZc2Z9oVGavsZPdSX8iGt/MCKEhW5o5iS6U1RPA== X-Received: by 2002:a81:9141:0:b0:57a:8ecb:11ad with SMTP id i62-20020a819141000000b0057a8ecb11admr8340512ywg.43.1692639571177; Mon, 21 Aug 2023 10:39:31 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id c128-20020a0dda86000000b0058d4eaa6fe0sm2358661ywe.52.2023.08.21.10.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 10:39:30 -0700 (PDT) Date: Mon, 21 Aug 2023 10:39:20 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Christian Brauner cc: Hugh Dickins , Andrew Morton , Oleksandr Tymoshenko , Carlos Maiolino , Jeff Layton , Chuck Lever , Jan Kara , Miklos Szeredi , Daniel Xu , Chris Down , Tejun Heo , Greg Kroah-Hartman , Matthew Wilcox , Christoph Hellwig , Pete Zaitcev , Helge Deller , Topi Miettinen , Yu Kuai , Franklin Mathieu , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH vfs.tmpfs] tmpfs,xattr: GFP_KERNEL_ACCOUNT for simple xattrs In-Reply-To: <20230810-notwehr-denkbar-3be0cc53a87a@brauner> Message-ID: References: <20230809-postkarten-zugute-3cde38456390@brauner> <20230809-leitgedanke-weltumsegelung-55042d9f7177@brauner> <20230810-notwehr-denkbar-3be0cc53a87a@brauner> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2FC5680006 X-Rspam-User: X-Stat-Signature: f9okeq7kgh1k7a9kgricct3r974jjb3c X-Rspamd-Server: rspam01 X-HE-Tag: 1692639572-471595 X-HE-Meta: U2FsdGVkX1+2LE1oi+rZ9tc6673dvAIjFPL4CIbWmdEqhcsF/n0yBPYrL77K52OMUtlmKcrdZ6aJBknnUXDZ8bbSBcN3JNcf426gm4/vfB8BCarAqywvDW9nPvDa8LDYpkpmREzZ+H7tekwoBVfvgYZMbRrwlS965voJV4sWEOAA8hkGXl+0+Cf6SqDlB7bw+qHhhhEp14Ot4O6VlD6uvKyXQ6GjyIja3mattb/Qzn6jBus57XSykxZLZSK7B74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ftQhLgZenO4MM8kFRnUIA6ZIw4iprJP3hPnplMdneI06Xct4bvZ8AkmNp4YJugiiYTdc7Ok4ecTS4zF4ux+s8D2m/rGQk/QKyafg2pn1Aeh2+SPUOSvX0OmbGbBbs6LzEBCLdg== 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: It is particularly important for the userns mount case (when a sensible nr_inodes maximum may not be enforced) that tmpfs user xattrs be subject to memory cgroup limiting. Leave temporary buffer allocations as is, but change the persistent simple xattr allocations from GFP_KERNEL to GFP_KERNEL_ACCOUNT. This limits kernfs's cgroupfs too, but that's good. (I had intended to send this change earlier, but had been confused by shmem_alloc_inode() using GFP_KERNEL, and thought a discussion would be needed to change that too: no, I was forgetting the SLAB_ACCOUNT on that kmem_cache, which implicitly adds __GFP_ACCOUNT to all its allocations.) Signed-off-by: Hugh Dickins Reviewed-by: Jan Kara --- fs/xattr.c | 4 ++-- mm/shmem.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index 2d607542281b..efd4736bc94b 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -1093,7 +1093,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size) if (len < sizeof(*new_xattr)) return NULL; - new_xattr = kvmalloc(len, GFP_KERNEL); + new_xattr = kvmalloc(len, GFP_KERNEL_ACCOUNT); if (!new_xattr) return NULL; @@ -1217,7 +1217,7 @@ struct simple_xattr *simple_xattr_set(struct simple_xattrs *xattrs, if (!new_xattr) return ERR_PTR(-ENOMEM); - new_xattr->name = kstrdup(name, GFP_KERNEL); + new_xattr->name = kstrdup(name, GFP_KERNEL_ACCOUNT); if (!new_xattr->name) { simple_xattr_free(new_xattr); return ERR_PTR(-ENOMEM); diff --git a/mm/shmem.c b/mm/shmem.c index b782edeb69aa..11298c797cdc 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3616,7 +3616,7 @@ static int shmem_initxattrs(struct inode *inode, len = strlen(xattr->name) + 1; new_xattr->name = kmalloc(XATTR_SECURITY_PREFIX_LEN + len, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (!new_xattr->name) { kvfree(new_xattr); break;