From patchwork Wed Nov 22 14:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13464937 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 2A380C61D97 for ; Wed, 22 Nov 2023 14:16:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FB146B0615; Wed, 22 Nov 2023 09:16:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A6E96B0616; Wed, 22 Nov 2023 09:16:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 823016B0617; Wed, 22 Nov 2023 09:16:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6D50A6B0615 for ; Wed, 22 Nov 2023 09:16:24 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4D034400B0 for ; Wed, 22 Nov 2023 14:16:24 +0000 (UTC) X-FDA: 81485790288.03.CA22899 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf19.hostedemail.com (Postfix) with ESMTP id 406651A0025 for ; Wed, 22 Nov 2023 14:16:20 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="WB4/PkmK"; spf=pass (imf19.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700662581; a=rsa-sha256; cv=none; b=cVVoElGw6pc7LPpdatrnS5unSN9p3BtNeGEZPHNA6yejxHGgL9Lb2h0C0Zz+WjEqcEnPnP UKeUMPCRZjzY0dkYxgIohh0KdOMkGrYHucXT5bj1s5s+HXTcF9IlgPicuLlehpgcUKvzA+ F2yec+D9kZVGowyFN4V9PA2fj7Qia6M= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="WB4/PkmK"; spf=pass (imf19.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=laoar.shao@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=1700662581; 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=wEKF8LLG6U3WOQ+0Jd5b+JaDhInk2g16roqp0OT/5iQ=; b=ampgsZEZ/L/RM/cf1+e5L7vOTGuTEM8ELP29m6SAmCezgoI97nhi6108e6uX8hjCP6WtgP mVMgtq2IaYL0Z6/BTUICdbOMyShJpz/yMTd8TLCEZrm68L1FBXG9H6Gsh4RGPYsiECBc/S 06QYvGYA0OiKBYMKiYmXXo0wVx5YBsw= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6b5cac99cfdso5931580b3a.2 for ; Wed, 22 Nov 2023 06:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700662580; x=1701267380; 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=wEKF8LLG6U3WOQ+0Jd5b+JaDhInk2g16roqp0OT/5iQ=; b=WB4/PkmK4QAi54ca5ZQCUWyBCxsqcdLQNEpABUU5Hh+CPoMbKwPL/HesE5uO89VLeV n0mbzmmqG0/7CbW4NSKxcocNBrFQOV0OJXWE5ir5UJ2wTKYM3Bz/woTZkIwHIL+h1UOn hvKV2bD3dG6EANgAg6RmgYuUeshH9VMzKP+6sXRMakB6BlJkhaFIVD9IFVdi1fPkb6eH 1G80NsD0e1ioGMONQPq7PmusWC92jAf0Ys2/8lYgUssZA4IGNfUJZZheGDzjaLKWltag pScQ0WAGWBK1r3TXCJ7ZLWFTNkd8/pT0LrqIhMCD8Sakr67ZrQXZyrkx8M16eVAzIJWY OHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700662580; x=1701267380; 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=wEKF8LLG6U3WOQ+0Jd5b+JaDhInk2g16roqp0OT/5iQ=; b=pMNtKFRmFdo2gT5djg7ST2TUqmiBw2EwboAlKTufSYkAcmKxZWTdcxz/eMyAujttIz 5jhFcUN/itcTXN3c7Pcz2GmByV9FZbskhUNdL2X+EcuCJHVQqAWfNswHTq6Mx2Jgy3Q8 XeQsqGKkmr6cbZz7AtFeByRVAtKgp28LVZOAv8XNbp0wmvwdrwfkVHP55AKajoGr5S/2 WzO4S5F0WUNfTWpZVr18hrUP0mMZjHY9iNyl9Aj6puin4OeK2oeIzDeK3XbFP96Z6XlN W0eAGb2yYR2M24lB3XLZQVvaTkYV+fQ4oNAQ04Bp0gj23OlVPp97uEioe6VB4+n+HT27 IwfQ== X-Gm-Message-State: AOJu0Yw6fgLPpPI2pk0pFqW8tCnNWclD+Ld86X0CQlKEriyZLPZ9PvG+ 1NkDOb9DWjTXFKPNB/wEDExFoJCrTUgZdQfX X-Google-Smtp-Source: AGHT+IHaW2MTTY6XpXzARVPEMKHa87mJ8Yxq3K7qITmUxY6o2gfygIc8izDK27aA06ZWTKsysRRh+w== X-Received: by 2002:a05:6a20:e126:b0:187:7917:189d with SMTP id kr38-20020a056a20e12600b001877917189dmr2568042pzb.29.1700662579836; Wed, 22 Nov 2023 06:16:19 -0800 (PST) Received: from vultr.guest ([2001:19f0:ac01:a71:5400:4ff:fea8:5687]) by smtp.gmail.com with ESMTPSA id p18-20020a63fe12000000b0058988954686sm9356260pgh.90.2023.11.22.06.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:16:19 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, omosnace@redhat.com, mhocko@suse.com Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, ligang.bdlg@bytedance.com, Yafang Shao , "Huang, Ying" Subject: [RFC PATCH v2 1/6] mm, doc: Add doc for MPOL_F_NUMA_BALANCING Date: Wed, 22 Nov 2023 14:15:54 +0000 Message-Id: <20231122141559.4228-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231122141559.4228-1-laoar.shao@gmail.com> References: <20231122141559.4228-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 406651A0025 X-Stat-Signature: rtji9w436z8xnwh7snctsbwpr1qk6uqz X-Rspam-User: X-HE-Tag: 1700662580-67076 X-HE-Meta: U2FsdGVkX1+/GPorCj1OWakPGb33b86VZdXhO9F28goiPQ6g44kew/2boKIMUpRi7IF2LodKawVF+CxLC0ZjS0Nk60S29MqITc7s5hzxT5UAtNxvZPaMOSfWRaCIeYZdKUKsJY/qTNSrwDASr8sWXNqGY6RglvilKwg0IlRNKWV4Db5c0DDN4M6B3gea4u7DSVAa4AWnAlQEncGxc9c3TX4UG4Iq8trAWQRkcq/UzH9erRyZQoINWZ3VHp8UequfA6ziUdYuWeosMkUtYxa3scTeIUjKqwR00GIBlixhVrNGJ8cUDoeJMJPAezZ8tWXpejr0j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gsly98e2wgQ2dRizRdMaCH/V1i+VrDr+VNuc5kSV8WB+kyKv5zrJtsALX7ft/ExBSyS4pJ/HKDFtIA1gLaTvZVIH5aQYMcMKZIicMx02hVF7XlmUcOAgnMCrLni49Zf2gQnQZ9BTDSowL8mTX1d498bzsxKiI7cxdLi4VTJ4yGR8Jbl3LhMHRJp2OZVBaP2lvOSzn5+6UxQw6Mp70rN5VdPFlU6lTS9XH13ZhQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The document on MPOL_F_NUMA_BALANCING was missed in the initial commit The MPOL_F_NUMA_BALANCING document was inadvertently omitted from the initial commit bda420b98505 ("numa balancing: migrate on fault among multiple bound nodes") Let's ensure its inclusion. Signed-off-by: Yafang Shao Cc: "Huang, Ying" Reviewed-by: "Huang, Ying" --- .../admin-guide/mm/numa_memory_policy.rst | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/admin-guide/mm/numa_memory_policy.rst b/Documentation/admin-guide/mm/numa_memory_policy.rst index eca38fa81e0f..19071b71979c 100644 --- a/Documentation/admin-guide/mm/numa_memory_policy.rst +++ b/Documentation/admin-guide/mm/numa_memory_policy.rst @@ -332,6 +332,33 @@ MPOL_F_RELATIVE_NODES MPOL_PREFERRED policies that were created with an empty nodemask (local allocation). +MPOL_F_NUMA_BALANCING (since Linux 5.12) + When operating in MPOL_BIND mode, enables NUMA balancing for tasks, + contingent upon kernel support. This feature optimizes page + placement within the confines of the specified memory binding + policy. The addition of the MPOL_F_NUMA_BALANCING flag augments the + control mechanism for NUMA balancing: + + - The sysctl knob numa_balancing governs global activation or + deactivation of NUMA balancing. + + - Even if sysctl numa_balancing is enabled, NUMA balancing remains + disabled by default for memory areas or applications utilizing + explicit memory policies. + + - The MPOL_F_NUMA_BALANCING flag facilitates NUMA balancing + activation for applications employing explicit memory policies + (MPOL_BIND). + + This flags enables various optimizations for page placement through + NUMA balancing. For instance, when an application's memory is bound + to multiple nodes (MPOL_BIND), the hint page fault handler attempts + to migrate accessed pages to reduce cross-node access if the + accessing node aligns with the policy nodemask. + + If the flag isn't supported by the kernel, or is used with mode + other than MPOL_BIND, -1 is returned and errno is set to EINVAL. + Memory Policy Reference Counting ================================ From patchwork Wed Nov 22 14:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13464939 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 17138C61D97 for ; Wed, 22 Nov 2023 14:16:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E6A86B0618; Wed, 22 Nov 2023 09:16:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 872886B0619; Wed, 22 Nov 2023 09:16:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E8386B061A; Wed, 22 Nov 2023 09:16:26 -0500 (EST) 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 4B2406B0619 for ; Wed, 22 Nov 2023 09:16:26 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 01CDF160C43 for ; Wed, 22 Nov 2023 14:16:25 +0000 (UTC) X-FDA: 81485790372.12.7FF7A8C Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf11.hostedemail.com (Postfix) with ESMTP id D50254002F for ; Wed, 22 Nov 2023 14:16:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=T3X7gGls; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@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=1700662582; 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=a1wPdyu7ENjoKkwP42urAAujwzKPPcBKgK7aJbdTPeE=; b=o0AcHbcXS0dB3AJgNop4zgkPmaS+NeKBNObul2tZOGop/jhSvEitRMdA/2ivWyjp2gqreZ PX57rVIO+QzGxM8AxoZZn8tID9WhJvszD22BezalFkfd417eMT+DvOewmtwRTr37ocM2OY NtgrqMCHwVmX/qjw0b/1dGlzhHmJemE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=T3X7gGls; spf=pass (imf11.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700662582; a=rsa-sha256; cv=none; b=yobvcNd9rZFq3T2/rOcboPB1LDIm0MLgS0QE6kdiYz5UgLLue8ZKxWl2WiZIYHQvTdw0LR kgAXLqfw8NnKRzC1l5mPpLwXy2gteJ7LMjmswwZGBwJWhCoCUwG1+K9srsLEELgo1/e4Ry qHrUeim2bf9rkm9KrTjXYNGW8KRIHcs= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6cbda959062so60624b3a.1 for ; Wed, 22 Nov 2023 06:16:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700662581; x=1701267381; 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=a1wPdyu7ENjoKkwP42urAAujwzKPPcBKgK7aJbdTPeE=; b=T3X7gGlsyop6RifXI0d82+pDWUndC4DhphlXZKFwSBH882LK7VUU3Z6YeJDUdb16ec 0Q9qmFyIoLi80ciatFq9W9qzFZmYwhiv2xvsSxGd6sSOEVrEVWudArhHvXAR/SCkB4xd s/n5slnyTQTnhsR3rzmoakkGje3jTPkRPgzsIKilteTVPcrqcvczQgl6jayhD25rzpkG RJrNmxhz3dmKX4+Cxvl/ksfRzA2FmxdMbYz9AwGaWsPml3CHy4nBPPUAVLFEFNuUAkUl 3UqC19GXUDaAROvmeLE8mR0BXMQC5qe9vKHwVX5b31bo+Ed83mD0h85M1R1MDorAexOZ /ygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700662581; x=1701267381; 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=a1wPdyu7ENjoKkwP42urAAujwzKPPcBKgK7aJbdTPeE=; b=ezguyIebOU3V2P0nFa0rcW8BFVhHAeSe2LJGnSC9L6UeGlUlsoUcZXhm8w+GDZzrPL g48lgC6YUfYw69N1uoS8kdyksrihH0oYzV7QEF0Ao3ur4ncvnJDYD6gbotGKW40Tqbie d3hrep2xl57jZlVOo9lYqdB80NSngywsqFeJKdMdu4W4gmvfJnLTqRtIU2+WThZ8Rmbu G3A6ymVmVW6ASNXAIOjvO3paWsO+I2eA7asob5NJarPDGI96yr98iJD4/w1MhNnWQaw2 xcgmorCrEhMRUoCruwCJU9cmdR1c1Fnmk7V0io4rT0rANM+dIvHWNtjEI8/OeID4zCbk n41Q== X-Gm-Message-State: AOJu0Yw4VlMrm+TO6HG5z2U0KFTdvyhjIxF7u1nSgH0MJjrx54IVsQmN mP8cWJSCTrvJkjwqGWVBOeM= X-Google-Smtp-Source: AGHT+IE6MKBa9DH0DLtzNahG0PY3BEbv8SQ3K8eKqp+aMh3wCYdSUNsYu1dxH5w+xaX+5VuH6wLbEA== X-Received: by 2002:a05:6a21:33a4:b0:18b:4a28:6e2d with SMTP id yy36-20020a056a2133a400b0018b4a286e2dmr1310481pzb.22.1700662581452; Wed, 22 Nov 2023 06:16:21 -0800 (PST) Received: from vultr.guest ([2001:19f0:ac01:a71:5400:4ff:fea8:5687]) by smtp.gmail.com with ESMTPSA id p18-20020a63fe12000000b0058988954686sm9356260pgh.90.2023.11.22.06.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:16:20 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, omosnace@redhat.com, mhocko@suse.com Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, ligang.bdlg@bytedance.com, Yafang Shao , Eric Dumazet , "Huang, Ying" Subject: [RFC PATCH v2 2/6] mm: mempolicy: Revise comment regarding mempolicy mode flags Date: Wed, 22 Nov 2023 14:15:55 +0000 Message-Id: <20231122141559.4228-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231122141559.4228-1-laoar.shao@gmail.com> References: <20231122141559.4228-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D50254002F X-Rspam-User: X-Stat-Signature: 9fukgkkqq4qjnrsyx1pw9ztw5t9zk34a X-Rspamd-Server: rspam01 X-HE-Tag: 1700662582-782136 X-HE-Meta: U2FsdGVkX1+0pUYjL8H8bFTe9HAMZUQVDXW7wBslVhRgSd8hHcySQP1U+3ZtpLYou0q6ILw5biXqQDpk89qqw2hX4Hlmc6BA9DyoDdDtmgCBjXGj1qmPvYm5fMONsf1T0giKDwH446YLoUpUdKYJs0anqGarz63Yo5Z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OFStmm2UQSyVHWl/PAJVve7zgdv7SjCa1fA50ZM5no2bCHUYN+3hl6wlSeacmDnApwyo9lllP0TW1IDSzhADzHFN7HZRuKOBbyRfvoJTLs88xC+BZfqlg59dm3p9MVfbgRfN29w8FfQgjmVGyZmhCuQirVIHA9zlrCSL61hL7ODIwqHIpbE4aqxAI9QPvPRxquh4b6GoG6ulrdOgQXG0Eb9d1Nc/IO7C14U+lQEtq/xJHESbhU7xQH7o0IWGLMGz1Ao3V3Scqq9gyD+j/0iwb7jySlW9LLnwRkdgMQu8rKoQ2zf26NGqSTzt8dhTtC36XJJJcIne3LxZgvKLU9cz24iHAE78Gq8lRu+hPB0P 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: List-Subscribe: List-Unsubscribe: MPOL_F_STATIC_NODES, MPOL_F_RELATIVE_NODES, and MPOL_F_NUMA_BALANCING are mode flags applicable to both set_mempolicy(2) and mbind(2) system calls. It's worth noting that MPOL_F_NUMA_BALANCING was initially introduced in commit bda420b98505 ("numa balancing: migrate on fault among multiple bound nodes") exclusively for set_mempolicy(2). However, it was later made a shared flag for both set_mempolicy(2) and mbind(2) following commit 6d2aec9e123b ("mm/mempolicy: do not allow illegal MPOL_F_NUMA_BALANCING | MPOL_LOCAL in mbind()"). This revised version aims to clarify the details regarding the mode flags. Signed-off-by: Yafang Shao Cc: Eric Dumazet Cc: "Huang, Ying" Reviewed-by: "Huang, Ying" --- include/uapi/linux/mempolicy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolicy.h index a8963f7ef4c2..afed4a45f5b9 100644 --- a/include/uapi/linux/mempolicy.h +++ b/include/uapi/linux/mempolicy.h @@ -26,7 +26,7 @@ enum { MPOL_MAX, /* always last member of enum */ }; -/* Flags for set_mempolicy */ +/* Flags for set_mempolicy() or mbind() */ #define MPOL_F_STATIC_NODES (1 << 15) #define MPOL_F_RELATIVE_NODES (1 << 14) #define MPOL_F_NUMA_BALANCING (1 << 13) /* Optimize with NUMA balancing if possible */ From patchwork Wed Nov 22 14:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13464938 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 08C7BC61D9C for ; Wed, 22 Nov 2023 14:16:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CC376B0617; Wed, 22 Nov 2023 09:16:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 254C86B0618; Wed, 22 Nov 2023 09:16:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F25CA6B0619; Wed, 22 Nov 2023 09:16:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DCD546B0617 for ; Wed, 22 Nov 2023 09:16:25 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B59E08016F for ; Wed, 22 Nov 2023 14:16:25 +0000 (UTC) X-FDA: 81485790330.12.80AAF95 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by imf28.hostedemail.com (Postfix) with ESMTP id C495CC0030 for ; Wed, 22 Nov 2023 14:16:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDenbw4Q; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.170 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700662583; a=rsa-sha256; cv=none; b=r664JoEFMZ30PIoltnJN7hCQfcH1zPIY8uDQf1tH20OO4QC74NkrRgDiQCDWsx0LHD/C10 eoAuplkjl0f1uwKeFORSKfVO3EhDkR3Xk4xCJl6hwEozXO5LMeyg+dpvh0hSz9RC4F6pIC tx4AaPtPBvMwYwLZTa5CkEHKedLfIfg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDenbw4Q; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.167.170 as permitted sender) smtp.mailfrom=laoar.shao@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=1700662583; 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=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=MZfK6ZO6q7an+D/ed2c4Mrijcm6OKLOMWsf5TZNI79GCui2ajMQyvj+Zd5nN5QAHgrQDCG teCY4u4UX4P1ZGGHF7f1ZAIyVE1t7FDqZgsJmWwSHWAvnKbSqAvVJt0R5vaGO+dqWuew0Z GgI/7Q5Hs9O5EoJJz8No3cucdR4xnzk= Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3b6d80daae8so4399306b6e.2 for ; Wed, 22 Nov 2023 06:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700662583; x=1701267383; 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=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=TDenbw4QcLu/22Cwet3m0s44NIFrhnVV40lQ0QXqt6ZRHF8xt4FmhRi3CenWIfZ1pP 97lG9BXWWZs0oFwaR/+xwShzeaU17XxIe4h2/TsXD5r0hg7jDdiDLKfnVlk+no1GfnpG Jv0fYA7keVnb/gLdzFMmNy6MxKcjbiLDFw+i2Hx5i2/X3rOmf0ll7nGuO/pf1BAupchh 8hvnY4S7BvuUjslz5nUi6k/kDPsnT5vucpodmJF96xmHxT0ZXCtgfHfPzxXYOczTBkRF 06mASav614pqF+CES60dAP3wlWZ7O640hF7Vzfubj0NxaV8JmKXfLP/DBgOEBSRPDTWH l2Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700662583; x=1701267383; 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=jCohkZOlhmClx79gxDRv3lIssVMr2jJPQS/93j1RD9I=; b=mLbPe2uL0ks6jgSB0JIydhtkIuhXIRs1aMynHqphNPo80Dg9sMMFgT6VGlTefjDGVk htyCR1NS/IlZSsqqA4v2B3tdBxDQgyD13q5CHp1CK0vXMhdPoWyILBHqXRvsxDd6iPQU mtV3z8xRaZITdIjwKgBIv43+a2zJxfgzqnU7nm/s1NnibXSHw9R94qGEqfIPR5UaXTGt lCzL5+HgENozSy35/4YZrI8rP54hZ8GU0nin0CjNOoeyVIzHVKH5yPCm5SQ5qelXEYjg urG8V3m5+2lNw39HDxbtNX4Yp7E7wqPrFZ9WvQ+JtNOPDnz2ZQxA+4UUajtjYI6t2apL xE4g== X-Gm-Message-State: AOJu0YxVGCSkr1EAM4beISkd5ETW9j6rZJGKxO8OBvtx+hIQspk9nUUV MDcIc46zyEqo3Bg8wna2ENw= X-Google-Smtp-Source: AGHT+IFPQzNlhHQv85DvH7rICMBG6EPDsKSzKKxxrGWE7E6Dc9LlipZ3FkuurVVO/TYfDh7rCoO6nw== X-Received: by 2002:a05:6808:f87:b0:3b2:f54b:8b1f with SMTP id o7-20020a0568080f8700b003b2f54b8b1fmr2792746oiw.35.1700662582831; Wed, 22 Nov 2023 06:16:22 -0800 (PST) Received: from vultr.guest ([2001:19f0:ac01:a71:5400:4ff:fea8:5687]) by smtp.gmail.com with ESMTPSA id p18-20020a63fe12000000b0058988954686sm9356260pgh.90.2023.11.22.06.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:16:22 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, omosnace@redhat.com, mhocko@suse.com Cc: linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, ligang.bdlg@bytedance.com, Yafang Shao Subject: [RFC PATCH v2 3/6] mm, security: Fix missed security_task_movememory() in mbind(2) Date: Wed, 22 Nov 2023 14:15:56 +0000 Message-Id: <20231122141559.4228-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231122141559.4228-1-laoar.shao@gmail.com> References: <20231122141559.4228-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C495CC0030 X-Stat-Signature: 46eexah6ow7tmwcdesqqb3dqh6hssyoe X-Rspam-User: X-HE-Tag: 1700662583-568625 X-HE-Meta: U2FsdGVkX19cp0msk+bM1ENi1U8+GHshBbke0OwKuW01MAYkrk+/OZouZwmEnb92XpaAcQglMOQuvFA7QaRgt5mvqUAweJ6yALvU0NCuIAqhq5xvR3lGvFZduQ+jJhHaCU+FeHiRGXm+OHh0xDd8cTZUnb7p4V8N/Yya+wg2NYSVDQhOPm8PY4SsGbTpXboHhs6GNem6G4XUNphqglIICWb6ZF0E23R6I+W1xI8lzhwmLX/VqvadCblZ+HXITGxxBlahWfbG+JZjWdQxevo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UQyMPcvKjHv7TgqvKT+LxUVY3O6kNRPnwyHZK8aONPJNf2E9AaTT4sQINVNAF6hbgbpGNHDrXecVkbW4FfTIC4TUFhOykmoPGl03PRXyboiw8y+1DmQ/ksB0nLxhQlPa47lZgnRwKizMD+HKZhspGiz45o0RkCDiEgr3xzjzdcCMMD2+5DWFhBxajVaJtImzbBGGO7rQRFlk7dPdk4tcdOerlK5b43WnYs+mY9YD9oFqYcgfvAcBLp9jnW9GIYBbgwdsr2433VvU/sw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.002938, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Considering that mbind(2) using either MPOL_MF_MOVE or MPOL_MF_MOVE_ALL is capable of memory movement, it's essential to include security_task_movememory() to cover this functionality as well. It was identified during a code review. Signed-off-by: Yafang Shao --- mm/mempolicy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..ded2e0e62e24 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1259,8 +1259,15 @@ static long do_mbind(unsigned long start, unsigned long len, if (!new) flags |= MPOL_MF_DISCONTIG_OK; - if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) + if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) { + err = security_task_movememory(current); + if (err) { + mpol_put(new); + return err; + } lru_cache_disable(); + } + { NODEMASK_SCRATCH(scratch); if (scratch) {