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: 150322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2115178vqo; Mon, 9 Oct 2023 13:54:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7qSSoUdf8kx60Q7ZlKLWu4z6XaHADP0Lkvhb1gv83lNJQEnS3OrxkabmNRsggKBok056K X-Received: by 2002:a17:902:e5c7:b0:1c5:b855:38f with SMTP id u7-20020a170902e5c700b001c5b855038fmr19481411plf.24.1696884848568; Mon, 09 Oct 2023 13:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696884848; cv=none; d=google.com; s=arc-20160816; b=WxXmic+wmFgk70u01n0G42fBjO1qwx0v7H1YVFeHgkjSY6f4SR+J+MC/u6IqPA4QhG /E6sDq3/F21fAkeWYzRUI5YBzzoyB51G+FLPNJnvQE7O0tfpalFo2Wxezdzstu2dEFaS AjfHLakH6Y+EFBPNjbzoRydnZ0CB8C3bxMOwjbj/m13hyn2yGf0/tlQbRgBFNxuY4qS3 n2Ep9RK+Ky2Xi+2lw3yPW8VYAAUsla7DGTg84rz/EIRmgRvnxDwr1ZEpu85zUFn7/cq9 74SPl8jpUPHBdNf2xKHUH6vu/HgoyUZZ3V8JBpZAafcCubFB+o0VxSrxA9fQOqYrx6ph ZKMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jochmgf2oxyHl1Fdsf6/Z0vhz675AmN7EMJ3Y7JXYH0=; fh=t0e8hB1yztay3y0yczBzLM0YwGerH6s+dnvwo2ZuqJs=; b=HnpocYx6P4W/zk9DsVDLYfvAt8G+K8q1ItIQAmNGiiz1fEdO59KgTmruT3IM9S4RoK aGWxXnW68tBl1Y9CcOzyb41BCuKgTMgYDE+2KyZfWWuAe6Fqg+pCtadpvCEMsKAjrJoC e0guB79syKHbpmPMq0jP5skH3O4SPkT8pbTqSN2jLr965zeetD671Q1D3Qy7rKdGCBt/ Y9Ax7Y+N12vq3enazqL5KHzhcmWlPDJCbL0zorELXazwNnDVsscf5St1eBM6tWpC079E M9M+zcvtLuOXYHRRTK5bONn9ZSP2k8k7zEqzbP2xDn41BlZCRxbq6YRuJXOrngMaP8Vd 66gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BlWJ928c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u7-20020a170903124700b001c752a540cdsi10700519plh.145.2023.10.09.13.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 13:54:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BlWJ928c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A61258116E47; Mon, 9 Oct 2023 13:54:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378026AbjJIUxn (ORCPT + 19 others); Mon, 9 Oct 2023 16:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377082AbjJIUxj (ORCPT ); Mon, 9 Oct 2023 16:53:39 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E80A6; Mon, 9 Oct 2023 13:53:36 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3226cc3e324so4909135f8f.3; 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=vger.kernel.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=BlWJ928czCmxUXHE9yDaFekmYQwrwx2M2dTJanSHnTnpcm46T43q+2BbSriIBCggCI omrl1Hfstn+EySkzfXES7l05BZrUMEGxPu8Ctszr2DakSA0ODmPzjdFBXTqAawUwHmj0 4ORfBid86/rdQzFAwUQ90zyDRafz5K+7ZXTPbB90eSciLoYvtUbwOyIqLea37vvXaIRV u4Yop//TPjkvD+Y+86Nk4OW2s8f1IRQ9IZE65DweR1lLxBE5qsI+2pmQkjcqsY2ThOBx 7HKphHQvdAo3ajbOjGs2/Mi81owBKUhZqXPYT+fFTG1yYOIVdbmAifiaWe2+DSEeKRuk bTZw== 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=hUBdnKbt1nxxm0tYc9wLT6/QT3L4uAetdR/b0h9wAZpIhQ5S8g+GnSGLldFnGReWwd fxl3m9vERc6Gx1ZYIxorP0nEpuKJ8u9xaF7uDND+Jzsc64TiSo+bCmoc8IWkQsWE/lQQ Lds3dU+PzyoGUepjAD1mFDMOqSOOJicqIDnvdKzmVfEhrYw4HetlfK6oF9el+oor7DOZ z2nKpaG8ITgBX0frc2PaZVprazC8cyPpeqFcytVJ9sS1u2GZN6BvGdpvL8E/zB/bXeTQ cn5vqGrkJ0IWSObPLGOg5NPmqQX8l61HL2R8TVmTHH/eJ5ywUNXJ1DangG23B4EKONOV aTgg== X-Gm-Message-State: AOJu0YzsRxZC4gVm4uXNZtcea7uKnBBXfJVx7kK5yXHt1NosP11fPoe5 seK08Ze2CG0Fs6xrhsJJu/8= 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-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 13:54:05 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779312726796003170 X-GMAIL-MSGID: 1779312726796003170 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;