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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E531C43219 for ; Wed, 13 Oct 2021 13:57:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C3D161100 for ; Wed, 13 Oct 2021 13:57:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C3D161100 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6E1FF6B006C; Wed, 13 Oct 2021 09:57:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66AC26B0071; Wed, 13 Oct 2021 09:57:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BDCB900002; Wed, 13 Oct 2021 09:57:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 372546B006C for ; Wed, 13 Oct 2021 09:57:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AB8A92B37D for ; Wed, 13 Oct 2021 13:57:39 +0000 (UTC) X-FDA: 78691567038.22.7B08645 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf17.hostedemail.com (Postfix) with ESMTP id 0F877F000392 for ; Wed, 13 Oct 2021 13:57:38 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19DDiqr5000381; Wed, 13 Oct 2021 09:57:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=IihffKGcUPmMJ3a5tn/7rkwdO4yJhhTGDQI0EXjZiRI=; b=m/bmbcTCQdpObvj6ANkssp31goMgsESX5+iURy4vHYTBgYTmBGfHE2PFa6R/7GO74zuR MJ9MIw+tRCu+7+mOCfvwsMY5Yt3iE9iY3OP91RI/FvVoaAhIoqAi+apImTICpz0gFBXk g1WcqqAYlSBgAQX3w/MHFVJzN/Px3avvvfAGCw5jmeb193/jCvykZhw/yoUUJJIF9UFd JeDUoKNiq2ZppszRZksvRJtzv+FWl++TE1r23xKq7Tt0B/dAY2Q7FT3/EXT9F/kWSahm /GcmKoJP+9/J3sVnMFp2FPO6slMpGAJDHq5AkNRJZlXm1ijug42KURM3YBn0IuuCUS6j tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bnprjd77p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Oct 2021 09:57:31 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19DDDC2P016897; Wed, 13 Oct 2021 09:57:31 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bnprjd776-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Oct 2021 09:57:30 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19DDlWwX023844; Wed, 13 Oct 2021 13:57:29 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3bk2qabf02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Oct 2021 13:57:28 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19DDvKAs45351248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Oct 2021 13:57:20 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7433EAE061; Wed, 13 Oct 2021 13:57:20 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 925DFAE06A; Wed, 13 Oct 2021 13:57:08 +0000 (GMT) Received: from [9.43.38.58] (unknown [9.43.38.58]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 13 Oct 2021 13:57:08 +0000 (GMT) Message-ID: <291424a2-c962-533e-c755-e4239fd55f5d@linux.ibm.com> Date: Wed, 13 Oct 2021 19:27:03 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [RFC PATCH] mm/mempolicy: add MPOL_PREFERRED_STRICT memory policy Content-Language: en-US From: "Aneesh Kumar K.V" To: Michal Hocko Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Ben Widawsky , Dave Hansen , Feng Tang , Andrea Arcangeli , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Andi Kleen , Dan Williams , Huang Ying , linux-api@vger.kernel.org References: <20211013094539.962357-1-aneesh.kumar@linux.ibm.com> <4399a215-296f-e880-c5f4-8065ab13d210@linux.ibm.com> <9a0baa59-f316-103f-3030-990cd91d1813@linux.ibm.com> In-Reply-To: <9a0baa59-f316-103f-3030-990cd91d1813@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-GUID: iOqfaxLJPHZ71LWO6y_2WHiZ8owaTpqB X-Proofpoint-ORIG-GUID: gWxYkwUQOHh4R9GBeUc0VBiur3ukgFVB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-13_05,2021-10-13_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 bulkscore=0 mlxlogscore=840 malwarescore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110130092 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="m/bmbcTC"; spf=pass (imf17.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0F877F000392 X-Stat-Signature: bhoconpetjc76f3decqudcfcjir98xtd X-HE-Tag: 1634133458-594286 Content-Transfer-Encoding: quoted-printable 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: On 10/13/21 18:28, Aneesh Kumar K.V wrote: > On 10/13/21 18:20, Michal Hocko wrote: >> On Wed 13-10-21 18:05:49, Aneesh Kumar K.V wrote: >>> On 10/13/21 16:18, Michal Hocko wrote: >>>> On Wed 13-10-21 12:42:34, Michal Hocko wrote: >>>>> [Cc linux-api] >>>>> >>>>> On Wed 13-10-21 15:15:39, Aneesh Kumar K.V wrote: >>>>>> This mempolicy mode can be used with either the set_mempolicy(2) >>>>>> or mbind(2) interfaces.=C2=A0 Like the MPOL_PREFERRED interface, i= t >>>>>> allows an application to set a preference node from which the kern= el >>>>>> will fulfill memory allocation requests. Unlike the MPOL_PREFERRED= =20 >>>>>> mode, >>>>>> it takes a set of nodes. The nodes in the nodemask are used as=20 >>>>>> fallback >>>>>> allocation nodes if memory is not available on the preferred node. >>>>>> Unlike MPOL_PREFERRED_MANY, it will not fall back memory allocatio= ns >>>>>> to all nodes in the system. Like the MPOL_BIND interface, it works= =20 >>>>>> over a >>>>>> set of nodes and will cause a SIGSEGV or invoke the OOM killer if >>>>>> memory is not available on those preferred nodes. >>>>>> >>>>>> This patch helps applications to hint a memory allocation=20 >>>>>> preference node >>>>>> and fallback to _only_ a set of nodes if the memory is not availab= le >>>>>> on the preferred node.=C2=A0 Fallback allocation is attempted from= the=20 >>>>>> node which is >>>>>> nearest to the preferred node. >>>>>> >>>>>> This new memory policy helps applications to have explicit control= =20 >>>>>> on slow >>>>>> memory allocation and avoids default fallback to slow memory NUMA=20 >>>>>> nodes. >>>>>> The difference with MPOL_BIND is the ability to specify a=20 >>>>>> preferred node >>>>>> which is the first node in the nodemask argument passed. >>>> >>>> I am sorry but I do not understand the semantic diffrence from >>>> MPOL_BIND. Could you be more specific please? >>>> >>> >>> >>> >>> MPOL_BIND >>> =C2=A0=C2=A0=C2=A0=C2=A0This mode specifies that memory must come fro= m the set of >>> =C2=A0=C2=A0=C2=A0=C2=A0nodes specified by the policy.=C2=A0 Memory w= ill be allocated from >>> =C2=A0=C2=A0=C2=A0=C2=A0the node in the set with sufficient free memo= ry that is >>> =C2=A0=C2=A0=C2=A0=C2=A0closest to the node where the allocation take= s place. >>> >>> >>> MPOL_PREFERRED_STRICT >>> =C2=A0=C2=A0=C2=A0=C2=A0This mode specifies that the allocation shoul= d be attempted >>> =C2=A0=C2=A0=C2=A0=C2=A0from the first node specified in the nodemask= of the policy. >>> =C2=A0=C2=A0=C2=A0=C2=A0If that allocation fails, the kernel will sea= rch other nodes >>> =C2=A0=C2=A0=C2=A0=C2=A0in the nodemask, in order of increasing dista= nce from the >>> =C2=A0=C2=A0=C2=A0=C2=A0preferred node based on information provided = by the platform =20 >>> firmware. >>> >>> The difference is the ability to specify the preferred node as the fi= rst >>> node in the nodemask and all fallback allocations are based on the=20 >>> distance >>> from the preferred node. With MPOL_BIND they base based on the node=20 >>> where >>> the allocation takes place. >> >> OK, this makes it more clear. Thanks! >> >> I am still not sure the semantic makes sense though. Why should >> the lowest node in the nodemask have any special meaning? What if it i= s >> a node with a higher number that somebody preferes to start with? >> >=20 > That is true. I haven't been able to find an easy way to specify the=20 > preferred node other than expressing it as first node in the node mask.= =20 > Yes, it limits the usage of the policy. Any alternate suggestion? >=20 > We could do > set_mempolicy(MPOLD_PREFERRED, nodemask(nodeX))) > set_mempolicy(MPOLD_PREFFERED_EXTEND, nodemask(fallback nodemask for=20 > above PREFERRED policy)) >=20 > But that really complicates the interface? >=20 > Another option is to keep this mbind(2) specific and overload flags to=20 be the preferred nodeid. mbind(va, len, MPOL_PREFERRED_STRICT, nodemask, max_node, preferred_node)= ; -aneesh