Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp37083pxb; Wed, 14 Apr 2021 08:53:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB+edaFffyRQsYU85Cb6uRjE8XukqN+Hvm2jkd6gJvAz3d21EqfBDtCoPdG6sTHovxCWfV X-Received: by 2002:a17:90b:389:: with SMTP id ga9mr4207175pjb.195.1618415634541; Wed, 14 Apr 2021 08:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618415634; cv=none; d=google.com; s=arc-20160816; b=PmpG1v6fRtVTu1mSj0iRZwql9Xg59Rb2r27TFT96quQvPV4vbFNBZVMAQpU8I5AngP 3j7Nj6pqEjoWxy+sLOF4fMEH+LBTB2WJ6U8n6+BxFER58FDMuwD3OofN/JD9sySsNlSs zo0U6pk8mujA/0LxWiTSbCdjA3Nt3JYXyQfu3BGOZnI8ipdD5BbR+2N8FdQAhSTi/r6/ cGzYS2lXkqekXDB57VRl0c7TlYzMINyKze3U6mYyRCF1mjJtW6uMAltbhgwycgc+m1h6 Gw3DvgrmDLPvfLC0wmpu4V7+23dZnCxFsh4OuvDb7kXeSgAYmQbYHYilvtV2lOCTeVNj rdhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IVVFe9lVz57JQCiJGdKdxrabbFt2psVmdL+WS1cz9u0=; b=RMLgSOVttc/jiMr+zXfM7vSB3bja4RIelZuQ+Tptm8gpjMJecZ4rXe15Zk7v26a8ML LYP3gJw+8rCLYflsoXQQkrw15fRRvts99tQpAC3GYve6WjBJtRXkRX/DBubaeb1PribF 0z1XGDKfqxH0CmaWrk3TzT/8LE6vOOhE5qeaSG+3JDv2OyRoJfhwp048oEH7LVqq/q2u Gm3qcTBMDMFtKawwl9BSnivRdBdTuNxjZZ5Dug3x+atf8uvstcnD7g7Gi1/szzT2Wuxe PF7Z0osa5P+onEbUZkjyjYXnfqlK3+Jw7tt7xuoLPMNmtNNmtPD8mxv1HX+EByxG8hJ/ 4H1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=S5QL89mv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si20520957pgn.13.2021.04.14.08.53.42; Wed, 14 Apr 2021 08:53:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=S5QL89mv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232904AbhDNM4D (ORCPT + 99 others); Wed, 14 Apr 2021 08:56:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:48430 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbhDNM4C (ORCPT ); Wed, 14 Apr 2021 08:56:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1618404940; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IVVFe9lVz57JQCiJGdKdxrabbFt2psVmdL+WS1cz9u0=; b=S5QL89mvzAHLxuE28gMdDkW7ratvQbt7wf6PzxucjX0wG64l2Z0/KUVICEJtjMD57BdyAq m97dquJ8tv1geZDYSJHmVRrZ/UJig1+1G43MEEbWpxLoRfw+E/z14m9lcHG8BxCJqBf8ra kU7pOhnXLnV9tBzhAAPm2IEBzu14sOc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 85977AFAB; Wed, 14 Apr 2021 12:55:40 +0000 (UTC) Date: Wed, 14 Apr 2021 14:55:39 +0200 From: Michal Hocko To: Feng Tang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Andrea Arcangeli , David Rientjes , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Dave Hansen , Ben Widawsky , Andi Kleen , Dan Williams , Dave Hansen Subject: Re: [PATCH v4 04/13] mm/mempolicy: allow preferred code to take a nodemask Message-ID: References: <1615952410-36895-1-git-send-email-feng.tang@intel.com> <1615952410-36895-5-git-send-email-feng.tang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1615952410-36895-5-git-send-email-feng.tang@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 17-03-21 11:40:01, Feng Tang wrote: > From: Dave Hansen > > Create a helper function (mpol_new_preferred_many()) which is usable > both by the old, single-node MPOL_PREFERRED and the new > MPOL_PREFERRED_MANY. > > Enforce the old single-node MPOL_PREFERRED behavior in the "new" > version of mpol_new_preferred() which calls mpol_new_preferred_many(). > > v3: > * fix a stack overflow caused by emty nodemask (Feng) > > Link: https://lore.kernel.org/r/20200630212517.308045-5-ben.widawsky@intel.com > Signed-off-by: Dave Hansen > Signed-off-by: Ben Widawsky > Signed-off-by: Feng Tang > --- > mm/mempolicy.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 1228d8e..6fb2cab 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -203,17 +203,34 @@ static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes) > return 0; > } > > -static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes) > +static int mpol_new_preferred_many(struct mempolicy *pol, > + const nodemask_t *nodes) > { > if (!nodes) > pol->flags |= MPOL_F_LOCAL; /* local allocation */ Now you have confused me. I thought that MPOL_PREFERRED_MANY for NULL nodemask will be disallowed as it is effectively MPOL_PREFERRED aka MPOL_F_LOCAL. Or do I misread the code? > else if (nodes_empty(*nodes)) > return -EINVAL; /* no allowed nodes */ > else > - pol->v.preferred_nodes = nodemask_of_node(first_node(*nodes)); > + pol->v.preferred_nodes = *nodes; > return 0; > } > > +static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes) > +{ > + if (nodes) { > + /* MPOL_PREFERRED can only take a single node: */ > + nodemask_t tmp; > + > + if (nodes_empty(*nodes)) > + return -EINVAL; > + > + tmp = nodemask_of_node(first_node(*nodes)); > + return mpol_new_preferred_many(pol, &tmp); > + } > + > + return mpol_new_preferred_many(pol, NULL); > +} > + > static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes) > { > if (nodes_empty(*nodes)) > -- > 2.7.4 -- Michal Hocko SUSE Labs