Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1137920imu; Fri, 7 Dec 2018 15:06:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/X0+he8+1ZMkxL+C1FXVqgY/tJPAylmwG7z0iVk+wQlEL6lJ5Np0zh64tUbIG5SElAKzkck X-Received: by 2002:a62:5182:: with SMTP id f124mr4112184pfb.238.1544223990064; Fri, 07 Dec 2018 15:06:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544223990; cv=none; d=google.com; s=arc-20160816; b=ShtRmE7GJDvK4rpe5Sju4MEkGFpYBlm5dEVJ5C5cwrQSCRk/trwxO0rMYyo6QI1+u5 mQsfcpWAxz+UgJdT4dpJQqKBd95qUHd5FwL5DQQ6rmCrJ1NpyWOufMXK0erQYGvap8a6 yzsesCpMuKYEHyQmQMsWTJ2MY4jTiqTb4pyUrIWBgQ5gvfl2G2ExiuNyz6EIZKo6/BJG VlB4/Tg6PzctS3WjaeYkYTGPZd3Pmb3kDDYTCaaZhnT7rQOwSc857pITFUOOTMVXAJDi xftaUVn54xcBLpwzKf6G8U4gwY7700wRTH9VamwLaHywJI3kYHdtyEijckrE1VC/YDmR MOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=pvY21zCNq3Q0MSKaFyLObZDxqXWhkh74H8m/h+IpBoE=; b=QJBP2gnd5CnJjMxsm9jDSxoc+URb4wuqjvLIq1XQZGZAITFWSMdODtlH6j1QhN0COe M5KceSjmR8xpNVZMeBeXUbdb9eGFDxgEAf6NcHMES04OJyQX3CZdKRWd2nwcnJWVYV1a AMD30t4nBNnoCqjqEEwqtfDr1vt5gXcd5aZHdwa7LpEK524B47R1CejAalaUlAny58HZ 3rV6A0ydWZJMovD4/VkHTN94w2q8k2OUGXBld24ShzZGZ+0W5UFy32LuNkFIbbc3/4UL gvg0hZTbW+2TB+l5lP3YjoAcXG1LTp+a0v6frW0y0xrZh8YzyEanIDgMubV95HKQx3lS yEuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UhkehH1o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si4155786pfg.121.2018.12.07.15.06.10; Fri, 07 Dec 2018 15:06:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UhkehH1o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbeLGXFb (ORCPT + 99 others); Fri, 7 Dec 2018 18:05:31 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:47055 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbeLGXFa (ORCPT ); Fri, 7 Dec 2018 18:05:30 -0500 Received: by mail-pf1-f193.google.com with SMTP id c73so2594743pfe.13 for ; Fri, 07 Dec 2018 15:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=pvY21zCNq3Q0MSKaFyLObZDxqXWhkh74H8m/h+IpBoE=; b=UhkehH1ogHxeR9vHbpLHeXG9xDrnfumxa/wGpCK/SX9ydXjBl6jYJ/60gFznZrLhYL OXxiPS6FoEsjdE0TozfcwuKh8oYY6jqQGH5O6gu0IEqWyjtlx1MMiijBya1nrWnq1EiO 4vVHvjJiBv21G3UhqMsz86cikuYAnValF4rNjMIZDy3yCcaA1JCym5qiFfUYduJAj/jW Os9wnILrcMSweRszTgbyp6vbPJgRoGNeAFAig+tL4T22sf5z/Yh/L0ESkknzxfmEj7oF rLEFZ/G61VVRrMojFRLHOt9k29PsVgbd18k2pUFPmD1C38GtM2MvPwS08oEsVBQsGE9m /C6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=pvY21zCNq3Q0MSKaFyLObZDxqXWhkh74H8m/h+IpBoE=; b=iilz6tYFfbpy1MwXJ9vu+7i6n31vqnn+YOfdC3jAeT6xLTYD8dhw65TrOEHX2M5+No kbdc3Hzm8TQacSHF/NBsByuRfW8tJLc/sZZBEPfdqaFNUhkpwPW4cshdLv5Gb5Xatbrx FBLCz3sRphzri6/tWueCgNmizZwRDkHOPD0VGcspfbATwr2Cm+46htuc2OdTcbKnzI7t Im59SD5AsV9k8sVVMd/1JqVHXKvqyN9qKdsuKSIvu/4obBCj3Zz/9mNH+HlRMO3Ap1LU Y2rEFIE0FCj5CiS5IU6ZR3BwZ0FB65WSyKoPSdcF0TTeMRY6PdOvxymKDqzMCVq6M5cl Uofg== X-Gm-Message-State: AA+aEWZpxBGeT0mJz/JmeLfSGzIfkFL/imTQGVJy3rHbYriF6t1XSwYX 7b4IitFOwCMp2QvF8ZbfHrETYA== X-Received: by 2002:a63:151f:: with SMTP id v31mr3551887pgl.34.1544223929748; Fri, 07 Dec 2018 15:05:29 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id t87sm12907625pfk.122.2018.12.07.15.05.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 15:05:28 -0800 (PST) Date: Fri, 7 Dec 2018 15:05:28 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: Linus Torvalds , Andrea Arcangeli , mgorman@techsingularity.net, Vlastimil Babka , ying.huang@intel.com, s.priebe@profihost.ag, Linux List Kernel Mailing , alex.williamson@redhat.com, lkp@01.org, kirill@shutemov.name, Andrew Morton , zi.yan@cs.rutgers.edu Subject: Re: [patch for-4.20] Revert "mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmask" In-Reply-To: <20181207080515.GT1286@dhcp22.suse.cz> Message-ID: References: <20181207080515.GT1286@dhcp22.suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 7 Dec 2018, Michal Hocko wrote: > > This reverts commit 89c83fb539f95491be80cdd5158e6f0ce329e317. > > > > There are a couple of issues with 89c83fb539f9 independent of its partial > > revert in 2f0799a0ffc0 ("mm, thp: restore node-local hugepage > > allocations"): > > > > Firstly, the interaction between alloc_hugepage_direct_gfpmask() and > > alloc_pages_vma() is racy wrt __GFP_THISNODE and MPOL_BIND. > > alloc_hugepage_direct_gfpmask() makes sure not to set __GFP_THISNODE for > > an MPOL_BIND policy but the policy used in alloc_pages_vma() may not be > > the same for shared vma policies, triggering the WARN_ON_ONCE() in > > policy_node(). > > Could you share a test case? > Sorry, as Vlastimil pointed out this race does not exist anymore since commit 2f0799a0ffc0 ("mm, thp: restore node-local hugepage allocations") since it removed the restructuring of alloc_hugepage_direct_gfpmask(). It existed prior to this commit for shared vma policies that could modify the policy between alloc_hugepage_direct_gfpmask() and alloc_pages_vma() if the policy switches to MPOL_BIND in that window. > > Secondly, prior to 89c83fb539f9, alloc_pages_vma() implemented a somewhat > > different policy for hugepage allocations, which were allocated through > > alloc_hugepage_vma(). For hugepage allocations, if the allocating > > process's node is in the set of allowed nodes, allocate with > > __GFP_THISNODE for that node (for MPOL_PREFERRED, use that node with > > __GFP_THISNODE instead). > > Why is it wrong to fallback to an explicitly configured mbind mask? > The new_page() case is similar to the shmem_alloc_hugepage() case. Prior to 89c83fb539f9 ("mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmask"), shmem_alloc_hugepage() did alloc_pages_vma() with hugepage == true, which effected a different allocation policy: if the node current is running on is allowed by the policy, use __GFP_THISNODE (considering ac5b2c18911ff is reverted, which it is in Linus's tree). After 89c83fb539f9, we lose that and can fallback to remote memory. Since the discussion is on-going wrt the NUMA aspects of hugepage allocations, it's better to have a stable 4.20 tree while that is being worked out and likely deserves separate patches for both new_page() and shmem_alloc_hugepage(). For the latter specifically, I assume it would be nice to get an Acked-by by Kirill who implemented shmem_alloc_hugepage() with hugepage == true back in 4.8 that also had the __GFP_THISNODE behavior before the allocation policy is suddenly changed.