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 1E4DEC433EF for ; Fri, 14 Jan 2022 22:06:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97B656B00F7; Fri, 14 Jan 2022 17:06:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92A176B00F9; Fri, 14 Jan 2022 17:06:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CB2A6B00FA; Fri, 14 Jan 2022 17:06:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 68CDF6B00F7 for ; Fri, 14 Jan 2022 17:06:10 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2563B182012AF for ; Fri, 14 Jan 2022 22:06:10 +0000 (UTC) X-FDA: 79030276500.05.06D0DB4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 85DB3180009 for ; Fri, 14 Jan 2022 22:06:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DACCB61FB7; Fri, 14 Jan 2022 22:06:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBEE6C36AE9; Fri, 14 Jan 2022 22:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642197968; bh=368je0VaVIJlFtzJl1GJqS8Yl6LTj8XhpVD9P1TcOwE=; h=Date:From:To:Subject:In-Reply-To:From; b=pFw/N6sKCa3XctkNyRuRAW8B6ve0OB1OFippsF6SGdGXvAybevXu2juH8kKwgs5VM vR2kRs8eK5YNMxsEuWskbZXfzJi3612VQ6zZyyva5EK4iM/dkpuqSzo30nYXMixZ4N fVsMs7hMzpFSJgeztZBRBw54KzIpj+1ZC+wlq/zU= Date: Fri, 14 Jan 2022 14:06:07 -0800 From: Andrew Morton To: akpm@linux-foundation.org, arnd@arndb.de, ccross@google.com, ebiederm@xmission.com, keescook@chromium.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, peterx@redhat.com, peterz@infradead.org, sfr@canb.auug.org.au, surenb@google.com, torvalds@linux-foundation.org, vbabka@suse.cz, viro@zeniv.linux.org.uk, willy@infradead.org, yuzhao@google.com Subject: [patch 059/146] mm: move anon_vma declarations to linux/mm_inline.h Message-ID: <20220114220607.ER5C3rmbo%akpm@linux-foundation.org> In-Reply-To: <20220114140222.6b14f0061194d3200000c52d@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 85DB3180009 X-Stat-Signature: 4oxd3us4cmkrdya5xbfwtjgtqmjqhww8 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="pFw/N6sK"; dmarc=none; spf=pass (imf06.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam02 X-HE-Tag: 1642197969-508430 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: From: Arnd Bergmann Subject: mm: move anon_vma declarations to linux/mm_inline.h The patch to add anonymous vma names causes a build failure in some configurations: include/linux/mm_types.h: In function 'is_same_vma_anon_name': include/linux/mm_types.h:924:37: error: implicit declaration of function 'strcmp' [-Werror=implicit-function-declaration] 924 | return name && vma_name && !strcmp(name, vma_name); | ^~~~~~ include/linux/mm_types.h:22:1: note: 'strcmp' is defined in header ''; did you forget to '#include '? This should not really be part of linux/mm_types.h in the first place, as that header is meant to only contain structure defintions and need a minimum set of indirect includes itself. While the header clearly includes more than it should at this point, let's not make it worse by including string.h as well, which would pull in the expensive (compile-speed wise) fortify-string logic. Move the new functions into a separate header that only needs to be included in a couple of locations. Link: https://lkml.kernel.org/r/20211207125710.2503446-1-arnd@kernel.org Fixes: "mm: add a field to store names for private anonymous memory" Signed-off-by: Arnd Bergmann Cc: Al Viro Cc: Colin Cross Cc: Eric Biederman Cc: Kees Cook Cc: Matthew Wilcox (Oracle) Cc: Peter Xu Cc: Peter Zijlstra (Intel) Cc: Stephen Rothwell Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Yu Zhao Signed-off-by: Andrew Morton --- fs/proc/task_mmu.c | 1 fs/userfaultfd.c | 1 include/linux/mm_inline.h | 50 ++++++++++++++++++++++++++++++++++++ include/linux/mm_types.h | 48 ---------------------------------- kernel/fork.c | 1 mm/madvise.c | 1 mm/mmap.c | 1 7 files changed, 55 insertions(+), 48 deletions(-) --- a/fs/proc/task_mmu.c~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/fs/proc/task_mmu.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include --- a/fs/userfaultfd.c~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/fs/userfaultfd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include --- a/include/linux/mm_inline.h~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/include/linux/mm_inline.h @@ -4,6 +4,7 @@ #include #include +#include /** * folio_is_file_lru - Should the folio be on a file LRU or anon LRU? @@ -135,4 +136,53 @@ static __always_inline void del_page_fro { lruvec_del_folio(lruvec, page_folio(page)); } + +#ifdef CONFIG_ANON_VMA_NAME +/* + * mmap_lock should be read-locked when calling vma_anon_name() and while using + * the returned pointer. + */ +extern const char *vma_anon_name(struct vm_area_struct *vma); + +/* + * mmap_lock should be read-locked for orig_vma->vm_mm. + * mmap_lock should be write-locked for new_vma->vm_mm or new_vma should be + * isolated. + */ +extern void dup_vma_anon_name(struct vm_area_struct *orig_vma, + struct vm_area_struct *new_vma); + +/* + * mmap_lock should be write-locked or vma should have been isolated under + * write-locked mmap_lock protection. + */ +extern void free_vma_anon_name(struct vm_area_struct *vma); + +/* mmap_lock should be read-locked */ +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, + const char *name) +{ + const char *vma_name = vma_anon_name(vma); + + /* either both NULL, or pointers to same string */ + if (vma_name == name) + return true; + + return name && vma_name && !strcmp(name, vma_name); +} +#else /* CONFIG_ANON_VMA_NAME */ +static inline const char *vma_anon_name(struct vm_area_struct *vma) +{ + return NULL; +} +static inline void dup_vma_anon_name(struct vm_area_struct *orig_vma, + struct vm_area_struct *new_vma) {} +static inline void free_vma_anon_name(struct vm_area_struct *vma) {} +static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, + const char *name) +{ + return true; +} +#endif /* CONFIG_ANON_VMA_NAME */ + #endif --- a/include/linux/mm_types.h~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/include/linux/mm_types.h @@ -890,52 +890,4 @@ typedef struct { unsigned long val; } swp_entry_t; -#ifdef CONFIG_ANON_VMA_NAME -/* - * mmap_lock should be read-locked when calling vma_anon_name() and while using - * the returned pointer. - */ -extern const char *vma_anon_name(struct vm_area_struct *vma); - -/* - * mmap_lock should be read-locked for orig_vma->vm_mm. - * mmap_lock should be write-locked for new_vma->vm_mm or new_vma should be - * isolated. - */ -extern void dup_vma_anon_name(struct vm_area_struct *orig_vma, - struct vm_area_struct *new_vma); - -/* - * mmap_lock should be write-locked or vma should have been isolated under - * write-locked mmap_lock protection. - */ -extern void free_vma_anon_name(struct vm_area_struct *vma); - -/* mmap_lock should be read-locked */ -static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, - const char *name) -{ - const char *vma_name = vma_anon_name(vma); - - /* either both NULL, or pointers to same string */ - if (vma_name == name) - return true; - - return name && vma_name && !strcmp(name, vma_name); -} -#else /* CONFIG_ANON_VMA_NAME */ -static inline const char *vma_anon_name(struct vm_area_struct *vma) -{ - return NULL; -} -static inline void dup_vma_anon_name(struct vm_area_struct *orig_vma, - struct vm_area_struct *new_vma) {} -static inline void free_vma_anon_name(struct vm_area_struct *vma) {} -static inline bool is_same_vma_anon_name(struct vm_area_struct *vma, - const char *name) -{ - return true; -} -#endif /* CONFIG_ANON_VMA_NAME */ - #endif /* _LINUX_MM_TYPES_H */ --- a/kernel/fork.c~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/kernel/fork.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include --- a/mm/madvise.c~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/mm/madvise.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include --- a/mm/mmap.c~mm-move-anon_vma-declarations-to-linux-mm_inlineh +++ a/mm/mmap.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include _