Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp347865pxb; Wed, 14 Apr 2021 17:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhPcbhmxHaLzxjwujSbJyZAzBJLITD3hMnQ2P7M4E44ckqIzJI2w1XXq79+TWCXSikM55q X-Received: by 2002:a17:90a:448b:: with SMTP id t11mr778483pjg.21.1618446379289; Wed, 14 Apr 2021 17:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618446379; cv=none; d=google.com; s=arc-20160816; b=NjUxthHHS9ZH635eVrmksyfH175w+HGTUMG88D0/kHyShvbbu6zANRiXKU0KfJKd0Y 2UtRalbX3Uc/aAwrzYXKMpOwB34SKe0P8XOn6Tnt9VMhcwrMJOEkRamVUVYXSJmetJni n0llvqsuSfqrrpBAIhQ7EhdjMZ3shx8r7QMksJPI2sldUe93dZHQn3Wo2FfWfLOPYnNs 6CnV3jcrmCbs/mXuFBlTMYUJcWgbQMqfdSLWkbEP9EjCIgHrFFaymrjuRHHP1LvX2dlp xTHX5r7imPMYmq8H0d9e7/5VxJttUcIOU/Wsmt4UXDJAM+GSkBV0Q9DkSXh+ps56mWIY JFvQ== 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=dE+HWKb+16i6cRgLpfVdufOcDPpR5dEzXtyzGBs68p8=; b=NYaSMP0r5r4pE6RKsEBb466ECWC0PbTjeDzgWQ63cCg3mZLUUzweLfLMo5qNWzDOG4 Ed44KVtsNWXqlUSx8nWWAI2C8E0uNe38zgOMRPkFr+AVm5HOP/81Q7ezfhBevQBERG1v r1QcfGwtHr0dNEjq/xjgslkwMN4m1Aw6Kf7Zw2WaeTxvvBo9TP5inMUf8etdkBflcZFs vH0rRMYt5nSJdCOV5X4btY1++F4/JeFQ5pwNxqAlkP+ME/S0Qw9PtwsWpWU63+HOE04Z LCULJEpjnLDKl39227GhNzi/AfXHMa813mFwHJnOiVvmHlS5Vdf+wFjFbn6h/8VE+P5k /sug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=sYJkBtwB; 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 cv7si599583pjb.160.2021.04.14.17.26.07; Wed, 14 Apr 2021 17:26:19 -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=sYJkBtwB; 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 S1351233AbhDNNPF (ORCPT + 99 others); Wed, 14 Apr 2021 09:15:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:60454 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351227AbhDNNOy (ORCPT ); Wed, 14 Apr 2021 09:14:54 -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=1618406072; 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=dE+HWKb+16i6cRgLpfVdufOcDPpR5dEzXtyzGBs68p8=; b=sYJkBtwBbUESpFpC95xC7R7I1ecRJEQ3oLvALnvVMQE6yV8vugBtpY9DsE5+5VOmyPMZhs nIzEITXIa1x0nEaI75a+wvD+lybZ1wEPe4XasG7MTpzRuVxP8DDmzAcGNeBPdyZj/jeA1d mCpaeUp+Hrb7a3N8ojq0DQD82ynWCsM= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5B364AEF8; Wed, 14 Apr 2021 13:14:32 +0000 (UTC) Date: Wed, 14 Apr 2021 15:14:31 +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 Subject: Re: [PATCH v4 10/13] mm/mempolicy: VMA allocation for many preferred Message-ID: References: <1615952410-36895-1-git-send-email-feng.tang@intel.com> <1615952410-36895-11-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-11-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:07, Feng Tang wrote: [...] > @@ -2301,10 +2300,26 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma, > * does not allow the current node in its nodemask, we allocate > * the standard way. > */ > - if ((pol->mode == MPOL_PREFERRED || > - pol->mode == MPOL_PREFERRED_MANY) && > - !(pol->flags & MPOL_F_LOCAL)) > + if (pol->mode == MPOL_PREFERRED || !(pol->flags & MPOL_F_LOCAL)) { > hpage_node = first_node(pol->nodes); > + } else if (pol->mode == MPOL_PREFERRED_MANY) { > + struct zoneref *z; > + > + /* > + * In this policy, with direct reclaim, the normal > + * policy based allocation will do the right thing - try > + * twice using the preferred nodes first, and all nodes > + * second. > + */ > + if (gfp & __GFP_DIRECT_RECLAIM) { > + page = alloc_pages_policy(pol, gfp, order, NUMA_NO_NODE); > + goto out; > + } > + > + z = first_zones_zonelist(node_zonelist(numa_node_id(), GFP_HIGHUSER), > + gfp_zone(GFP_HIGHUSER), &pol->nodes); > + hpage_node = zone_to_nid(z->zone); > + } > > nmask = policy_nodemask(gfp, pol); > if (!nmask || node_isset(hpage_node, *nmask)) { > @@ -2330,9 +2345,7 @@ alloc_pages_vma(gfp_t gfp, int order, struct vm_area_struct *vma, > } > } > > - nmask = policy_nodemask(gfp, pol); > - preferred_nid = policy_node(gfp, pol, node); > - page = __alloc_pages_nodemask(gfp, order, preferred_nid, nmask); > + page = alloc_pages_policy(pol, gfp, order, NUMA_NO_NODE); > mpol_cond_put(pol); > out: > return page; OK, it took me a while to grasp this but the code is a mess I have to say. Not that it was an act of beauty before but this just makes it much harder to follow. And alloc_pages_policy doesn't really help I have to say. I would have expected that a dedicated alloc_pages_preferred and a general fallback to __alloc_pages_nodemask would have been much easier to follow. -- Michal Hocko SUSE Labs