From patchwork Mon Oct 9 20:53:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13414429 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 77593CD612F for ; Mon, 9 Oct 2023 20:53:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB73A8D008E; Mon, 9 Oct 2023 16:53:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A670F8D0089; Mon, 9 Oct 2023 16:53:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E12D8D008E; Mon, 9 Oct 2023 16:53:38 -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 799578D0089 for ; Mon, 9 Oct 2023 16:53:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4EFBB40370 for ; Mon, 9 Oct 2023 20:53:38 +0000 (UTC) X-FDA: 81327124116.27.4AEA5E8 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf11.hostedemail.com (Postfix) with ESMTP id 65B7D40012 for ; Mon, 9 Oct 2023 20:53:36 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FvjSx/EW"; spf=pass (imf11.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696884816; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jochmgf2oxyHl1Fdsf6/Z0vhz675AmN7EMJ3Y7JXYH0=; b=Z5sMADaY/y6q9YZZSYTcCNyuvjU1G0AUR3TO3P3LYaSrTsL2UgM8BGQbseAdFXfBvaJPrO Gxnx2DME1kmNjDb37n4UC6cHTjHm4SQavYPMA9aCAmdKK4IT+qJrjoK01ypTef4sHOnSyQ fIXux4UcWJ6nQwqB5iemN/yrJQiXxLU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696884816; a=rsa-sha256; cv=none; b=5abdAew3eRyLljVHbJ86ioDblqpkBoxiMkUoomWX/A+vPpr4NY84CkZnkwc4vX4dJREioR 2rzmi/bOfaLBYavW/hwdqtgZcefBnE2LD3becn2uvQDVgjIWgYqW/gL6ISdaUNqUUM4xQF GWGbK0t/8vv9WQTlfcyrLFNWGfUkM7o= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FvjSx/EW"; spf=pass (imf11.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40535597f01so46921615e9.3 for ; Mon, 09 Oct 2023 13:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696884815; x=1697489615; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jochmgf2oxyHl1Fdsf6/Z0vhz675AmN7EMJ3Y7JXYH0=; b=FvjSx/EWYS+QbnuGEZJhBTNQ1XAkMQ2Kqx26RhH1rx5Vq3CUYs42oIrEksHE/UfIfP AmfRUGDgPpTIoSdiX9H5RFLeynrb4seUz7bJuAXEH+bkgMESVeBFSyRRxfcL+dwnFvPN gXmXrY0fT90WjGhkun80Ug67ySCLQHtB10bgWiDHMWj1SjKMwoTgbyntSYTmaLynx+Vj 0/uMHlXGHN2fgLGQfZpY3PguK/OznllvOjGzAOjwY3djSvNHQkG2UKmd3phhrpBP9ef3 4fJNX2FHsXbKVa0G97vAq0gHhMHbEBuxpJrXU0am68KBqpYek7QvM0yCkiGESZaVycQ4 1Zsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696884815; x=1697489615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jochmgf2oxyHl1Fdsf6/Z0vhz675AmN7EMJ3Y7JXYH0=; b=JQXCph4Qo/FfwBr8ILeGK/OpqnEtWhnsDI3yonicLd+2tWK+zR65ajDLxl7Z2l8TPP MnV1cHE/A3KStx3d/6j8JHx0uoyv4s63EHL9nq61/9/vZ8ukrH24jFYet4g1BF1rX7dT iO1qvD3mpNT8yyRC+/jjPb0QmVWQMQhmhXgM1DbDbUDZ1h39zza/CIV8AnRePzWZ9nmA 48nUMX9KjlWII4lOx6KsqW9pw/nHxMjHs+lrUCZdYNntHCOGB2kyeC2nXLiJRuqg1lta BowOU43ZlohdfBqMVj5YhgfTzwEtCC8OAG+4lGBGAa1e2jFIvcUY2E8p4THMDFF5mfeH M46Q== X-Gm-Message-State: AOJu0YxPE0k+Kn3oH3Bw6jP+cPBXNrZJIURFJl+GNeQO+dBEyJOSu4ax TcJcJ7ePWQtS0NoxrJvYcojiQWjXcBA= X-Google-Smtp-Source: AGHT+IEili6yjcpf1CIpTHpX1KIvbP9i7YisloKuaIxOeqWIbartUF3HE3nQKw8VeOEZ+cxXGxy9ng== X-Received: by 2002:a5d:4dcc:0:b0:321:62b0:7ad8 with SMTP id f12-20020a5d4dcc000000b0032162b07ad8mr14148854wru.16.1696884814438; Mon, 09 Oct 2023 13:53:34 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id l2-20020a5d4802000000b0031fe0576460sm10578130wrq.11.2023.10.09.13.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:53:33 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Alexander Viro , Christian Brauner Cc: "=Liam R . Howlett" , Vlastimil Babka , linux-fsdevel@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH v2 1/5] mm: move vma_policy() and anon_vma_name() decls to mm_types.h Date: Mon, 9 Oct 2023 21:53:16 +0100 Message-ID: <4f1063f9c0e05ada89458083476e03434498e81e.1696884493.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: 1aybyh6jqhcqkkrehzajtn6pqw77c5xi X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 65B7D40012 X-Rspam-User: X-HE-Tag: 1696884816-376705 X-HE-Meta: U2FsdGVkX18QiP3uNd3zNLoF8KxNfocNZlGdWub2q5xy37dxdHSQhr07GKjwhgOeDBIOJioneqDPmcpmBKJeKc/3eB0/qeO7UFGrxG6fWoVPBAmeciUwKyvYNP4LO+pLh65I/vVzSs2pIqDfjWuZ3s8TOwnuA0EysDCMhqYOWDY28IH5sIl+36DiDR0Nu0qy5eOFInYhAR/eCRXd0ko/UqQR6w2uabv2Vxh4AVL3L6eVhdJA2M26oWp8vEUWiKVzDAy9GOVzcfOxq/WGGKLdJjBOvDmwIpNDfd01pe4OHON+mHX3w/k/i4k45kHxJJnIg/UYZX317euXQvJt9K17KF2Yjwm9WmLs6rk6Xc6EOVMwuWmxfJQQ4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oMnbQrggQS20IULFB1ZkSJ1ve09oQCjh 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: The vma_policy() define is a helper specifically for a VMA field so it makes sense to host it in the memory management types header. The anon_vma_name(), anon_vma_name_alloc() and anon_vma_name_free() functions are a little out of place in mm_inline.h as they define external functions, and so it makes sense to locate them in mm_types.h. The purpose of these relocations is to make it possible to abstract static inline wrappers which invoke both of these helpers. Signed-off-by: Lorenzo Stoakes Reviewed-by: Vlastimil Babka --- include/linux/mempolicy.h | 4 ---- include/linux/mm_inline.h | 20 +------------------- include/linux/mm_types.h | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 3c208d4f0ee9..2801d5b0a4e9 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -89,8 +89,6 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol) return pol; } -#define vma_policy(vma) ((vma)->vm_policy) - static inline void mpol_get(struct mempolicy *pol) { if (pol) @@ -222,8 +220,6 @@ static inline struct mempolicy *get_vma_policy(struct vm_area_struct *vma, return NULL; } -#define vma_policy(vma) NULL - static inline int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst) { diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 8148b30a9df1..9ae7def16cb2 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -352,15 +353,6 @@ void lruvec_del_folio(struct lruvec *lruvec, struct folio *folio) } #ifdef CONFIG_ANON_VMA_NAME -/* - * mmap_lock should be read-locked when calling anon_vma_name(). Caller should - * either keep holding the lock while using the returned pointer or it should - * raise anon_vma_name refcount before releasing the lock. - */ -extern struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma); -extern struct anon_vma_name *anon_vma_name_alloc(const char *name); -extern void anon_vma_name_free(struct kref *kref); - /* mmap_lock should be read-locked */ static inline void anon_vma_name_get(struct anon_vma_name *anon_name) { @@ -415,16 +407,6 @@ static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1, } #else /* CONFIG_ANON_VMA_NAME */ -static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma) -{ - return NULL; -} - -static inline struct anon_vma_name *anon_vma_name_alloc(const char *name) -{ - return NULL; -} - static inline void anon_vma_name_get(struct anon_vma_name *anon_name) {} static inline void anon_vma_name_put(struct anon_vma_name *anon_name) {} static inline void dup_anon_vma_name(struct vm_area_struct *orig_vma, diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 36c5b43999e6..21eb56145f57 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -546,6 +546,27 @@ struct anon_vma_name { char name[]; }; +#ifdef CONFIG_ANON_VMA_NAME +/* + * mmap_lock should be read-locked when calling anon_vma_name(). Caller should + * either keep holding the lock while using the returned pointer or it should + * raise anon_vma_name refcount before releasing the lock. + */ +struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma); +struct anon_vma_name *anon_vma_name_alloc(const char *name); +void anon_vma_name_free(struct kref *kref); +#else /* CONFIG_ANON_VMA_NAME */ +static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma) +{ + return NULL; +} + +static inline struct anon_vma_name *anon_vma_name_alloc(const char *name) +{ + return NULL; +} +#endif + struct vma_lock { struct rw_semaphore lock; }; @@ -662,6 +683,12 @@ struct vm_area_struct { struct vm_userfaultfd_ctx vm_userfaultfd_ctx; } __randomize_layout; +#ifdef CONFIG_NUMA +#define vma_policy(vma) ((vma)->vm_policy) +#else +#define vma_policy(vma) NULL +#endif + #ifdef CONFIG_SCHED_MM_CID struct mm_cid { u64 time;