The patch titled Subject: tmpfs,xattr: GFP_KERNEL_ACCOUNT for simple xattrs has been added to the -mm mm-unstable branch. Its filename is tmpfsxattr-gfp_kernel_account-for-simple-xattrs.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tmpfsxattr-gfp_kernel_account-for-simple-xattrs.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Hugh Dickins <hughd@xxxxxxxxxx> Subject: tmpfs,xattr: GFP_KERNEL_ACCOUNT for simple xattrs Date: Mon, 21 Aug 2023 10:39:20 -0700 (PDT) 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.) Link: https://lkml.kernel.org/r/f6953e5a-4183-8314-38f2-40be60998615@xxxxxxxxxx Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> Reviewed-by: Jan Kara <jack@xxxxxxx> Cc: Carlos Maiolino <cem@xxxxxxxxxx> Cc: Chris Down <chris@xxxxxxxxxxxxxx> Cc: "Christian Brauner (Microsoft)" <brauner@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> Cc: Chuck Lever <chuck.lever@xxxxxxxxxx> Cc: Daniel Xu <dxu@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Helge Deller <deller@xxxxxx> Cc: Jeff Layton <jlayton@xxxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Miklos Szeredi <miklos@xxxxxxxxxx> Cc: Pete Zaitcev <zaitcev@xxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: Topi Miettinen <toiwoton@xxxxxxxxx> Cc: Yu Kuai <yukuai3@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/xattr.c | 4 ++-- mm/shmem.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/fs/xattr.c~tmpfsxattr-gfp_kernel_account-for-simple-xattrs +++ a/fs/xattr.c @@ -1073,7 +1073,7 @@ struct simple_xattr *simple_xattr_alloc( 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; @@ -1200,7 +1200,7 @@ int simple_xattr_set(struct simple_xattr if (!new_xattr) return -ENOMEM; - new_xattr->name = kstrdup(name, GFP_KERNEL); + new_xattr->name = kstrdup(name, GFP_KERNEL_ACCOUNT); if (!new_xattr->name) { free_simple_xattr(new_xattr); return -ENOMEM; --- a/mm/shmem.c~tmpfsxattr-gfp_kernel_account-for-simple-xattrs +++ a/mm/shmem.c @@ -3445,7 +3445,7 @@ static int shmem_initxattrs(struct 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); return -ENOMEM; _ Patches currently in -mm which might be from hughd@xxxxxxxxxx are arm-include-asm-cacheflushh-in-asm-hugetlbh.patch arm64-include-asm-cacheflushh-in-asm-hugetlbh.patch riscv-include-asm-cacheflushh-in-asm-hugetlbh.patch mmthp-no-space-after-colon-in-mem-info-fields.patch mmthp-fix-noden-meminfo-output-alignment.patch mmthp-fix-smaps-thpeligible-output-alignment.patch tmpfsxattr-gfp_kernel_account-for-simple-xattrs.patch