From patchwork Tue Jun 30 21:25:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 11634829 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E16C739 for ; Tue, 30 Jun 2020 21:25:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 047EC2072D for ; Tue, 30 Jun 2020 21:25:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 047EC2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E76778D000B; Tue, 30 Jun 2020 17:25:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D5E518D000A; Tue, 30 Jun 2020 17:25:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C027D8D0009; Tue, 30 Jun 2020 17:25:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id 9EE0B8D0007 for ; Tue, 30 Jun 2020 17:25:29 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 62B6C8248068 for ; Tue, 30 Jun 2020 21:25:29 +0000 (UTC) X-FDA: 76987159578.03.birds93_2d0b20026e7b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 3363E28A4E9 for ; Tue, 30 Jun 2020 21:25:29 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,ben.widawsky@intel.com,,RULES_HIT:30012:30054:30064,0,RBL:192.55.52.136:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95;04ygruwug37yd6cpnbszgx4oyesu8ycntjrxyxutj7oru8zf91tbzg79p1bssjs.uwygyqrufmjy9d6mopy9hqgq1dtuett6jdjisxi6zp35hnw5gz4t99u44whppei.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: birds93_2d0b20026e7b X-Filterd-Recvd-Size: 3600 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 30 Jun 2020 21:25:27 +0000 (UTC) IronPort-SDR: KucV2/BGc+aDgZeYKkKp+uIoTLKm+6LvUFhhT86oZ9BJsNfXrlBc6AltIL0IXVcypksJZijvx4 fQHAMpjmgyBQ== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="126011316" X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="126011316" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 14:25:23 -0700 IronPort-SDR: cA821hHlmTE2NiSTAOgHl5UlpxdCUWDkRaE6ceH/S074++WSfveBc1T2NQ4PPRjFo/FRFCZHo0 t1fnhyXlrwPQ== X-IronPort-AV: E=Sophos;i="5.75,298,1589266800"; d="scan'208";a="481336263" Received: from schittin-mobl.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.132.42]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 14:25:23 -0700 From: Ben Widawsky To: linux-mm , linux-kernel@vger.kernel.org Cc: Michal Hocko , Dave Hansen , Dave Hansen , Andrew Morton , Randy Dunlap , Ben Widawsky Subject: [PATCH 04/12] mm/mempolicy: allow preferred code to take a nodemask Date: Tue, 30 Jun 2020 14:25:09 -0700 Message-Id: <20200630212517.308045-5-ben.widawsky@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200630212517.308045-1-ben.widawsky@intel.com> References: <20200630212517.308045-1-ben.widawsky@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3363E28A4E9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: 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(). Cc: Andrew Morton Cc: Randy Dunlap Signed-off-by: Dave Hansen Signed-off-by: Ben Widawsky Reported-by: kernel test robot --- mm/mempolicy.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 33bf29ddfab2..1ad6e446d8f6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -203,17 +203,30 @@ 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 */ 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 = 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))