Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1846333imn; Mon, 1 Aug 2022 02:16:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AJMatMo1G5OOTRcsvUKMfzztORoAnD0tPp0eewz89uxPBSB0QJI/+vGlJw1P2mAqZWs6F X-Received: by 2002:a05:6402:b84:b0:43d:962d:7db1 with SMTP id cf4-20020a0564020b8400b0043d962d7db1mr5019527edb.270.1659345390498; Mon, 01 Aug 2022 02:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659345390; cv=none; d=google.com; s=arc-20160816; b=LlpEYZv1gpA0SmRn6cr70cyovfH8zefu7mDopzchJ1w8fFHxK3sOmN475bVBtOKhDL iIagH2Dtnj6/iukBIOu4SunmEFMmaupNRYiFE8+qVPn4Gq+gVCA5MXOBK0sed+dU/N2c ZsqZrwqnW4xHfW7YcqejxuWRowrCCr3RHr32fu49lKceZ+sXbvvIlEJg4hmhDdV1nXle lbuMqbJynRM0WUP2+P84pC9hhakfDS7apK5eJG1uibj7bSvUBcQYRxtui8Xf2xdbOuPB w6Itglupotaha8Nq8zKgrgSZjHjCwYZ1wVoz2bVUmyHkg8LyOT+8VX5x4DxN+jT/hABN oE0Q== 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=4t5FS/Ddvx7aCW3ILaNh8gtZfbccK8EChN8c9861jBc=; b=up9ZmaF3txFM6UxRlnlADFKjY5rKNGK6ey1b+jqZrD0XSV1KW8imlO4bOSdpyR2YNr kFIVke+F53wfzgn/zRSLkQl+9VO8qGlkczhLlsvtwIO6ERd2EGyO7DKt/Sr0K4xDlJG4 Z+4X47HKomUyW1A/p/q9E6neaRQCn5gykqC+EYqqu7pAT4t+YZvPKQrbiKMFc8ZFkQgd yyuV4cvuuk3ADWoMZ8l9PaKVZRxXMvRt/V1uNpPLgJr4cmXnC/zT8MiRLADXaCJnKGfC G2X9Ca96dayehrx56g4Ls0wAYSiI8I6ERkJQZpsadAzGIeYhKIXwlYW/jOztHYSvfGGV +IHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=fUwRp6L0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc19-20020a1709078a1300b006f4d14bbbb3si8506179ejc.150.2022.08.01.02.16.05; Mon, 01 Aug 2022 02:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=fUwRp6L0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbiHAJGV (ORCPT + 99 others); Mon, 1 Aug 2022 05:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiHAJGS (ORCPT ); Mon, 1 Aug 2022 05:06:18 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B09B255BE for ; Mon, 1 Aug 2022 02:06:16 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2C7C161058; Mon, 1 Aug 2022 09:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1659344775; 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=4t5FS/Ddvx7aCW3ILaNh8gtZfbccK8EChN8c9861jBc=; b=fUwRp6L0M0aa9LCEIZqXo1N+WO84MIDjhZZ9CbWDwsV/gQu75ZXS2d+W4lTFA6NKaRrHDr 9P+OWOwC47ntmhq48jJLMlimlzGWUX7q0TTEhGkIBuLtZ6e8gLt66FzLFTiAlwaJvp7Ug3 F/N3FPv8eVipcNxLgQ010G8aBPyyy+4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 06DC213A72; Mon, 1 Aug 2022 09:06:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eOYfOoaX52K9PQAAMHmgww (envelope-from ); Mon, 01 Aug 2022 09:06:14 +0000 Date: Mon, 1 Aug 2022 11:06:14 +0200 From: Michal Hocko To: Muchun Song Cc: akpm@linux-foundation.org, bwidawsk@kernel.org, dave.hansen@linux.intel.com, feng.tang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: mempolicy: fix policy_nodemask() for MPOL_PREFERRED_MANY case Message-ID: References: <20220801084207.39086-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220801084207.39086-1-songmuchun@bytedance.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 01-08-22 16:42:07, Muchun Song wrote: > policy_nodemask() is supposed to be returned a nodemask representing a mempolicy > for filtering nodes for page allocation, which is a hard restriction (see the user > of allowed_mems_nr() in hugetlb.c). However, MPOL_PREFERRED_MANY is a preferred > mode not a hard restriction. Now it breaks the user of HugeTLB. Remove it from > policy_nodemask() to fix it, which will not affect current users of policy_nodemask() > since all of the users already have handled the case of MPOL_PREFERRED_MANY before > calling it. BTW, it is found by code inspection. I am not sure this is the right fix. It is quite true that policy_nodemask is a tricky function to use. It pretends to have a higher level logic but all existing users are expected to be policy aware and they special case allocation for each policy. That would mean that hugetlb should do the same. I haven't checked the actual behavior implications for hugetlb here. Is MPOL_PREFERRED_MANY even supported for hugetlb? Does this change make it work? From a quick look this just ignores MPOL_PREFERRED_MANY completely. > Fixes: b27abaccf8e8 ("mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes") > Signed-off-by: Muchun Song > --- > mm/mempolicy.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 6c27acb6cd63..4deec7e598c6 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -1845,9 +1845,6 @@ nodemask_t *policy_nodemask(gfp_t gfp, struct mempolicy *policy) > cpuset_nodemask_valid_mems_allowed(&policy->nodes)) > return &policy->nodes; > > - if (mode == MPOL_PREFERRED_MANY) > - return &policy->nodes; > - > return NULL; > } > > -- > 2.11.0 -- Michal Hocko SUSE Labs