Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2179076pxj; Thu, 20 May 2021 01:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq8LNcv45+qVZdnpm5hw5Xqnb490aEKqdOdNJQ76GGAk7z6nXUbryu6n1IPrJQzzLuqycl X-Received: by 2002:a17:906:a285:: with SMTP id i5mr3683427ejz.350.1621500576189; Thu, 20 May 2021 01:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621500576; cv=none; d=google.com; s=arc-20160816; b=UwD7zfePF+VHCzN+OBoiZZKS8mP5WcK4o4j2nvaC1gpjhNGfuY7I7XHp55dbvwd/Mt I9JPwB8YPOaHEf8K/MODEkqPa4EOJriX0fI/Opk93zjOiK5ArH+ylzEBRGXcU/14EBhH z72RnAnbgpXlLtDT/voe2ChBkppsOweqzkkWd5J8ABCMSlupdX8/vehy4RD/Oep1XDZ/ Dk+oZmHfUFtoSU5gr1zKk/aDu12msY4ZrVOqRaiCtYL0M56ot7ONXVoRQCUrwkGY3YH5 14S65NtZ7ptN231gejnV2QH+tM0U6m/Q4ctzKKXsSr8UAVUg8SgFApavOv7r438bf0Ua P8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=Mwojytkjppcn6xXBGxNeN1oFZPYMzKgblWXBSJ9aXFM=; b=0sBLFTkau7uklrmocroQl2Xe/TB6QZOgPeibACM28Mm7iOMiIp9PDxP/1Ej6dA2sVk WyAeRSf+WMlW80K58WPNeEGJdaN5guzXNfU/V1BEDi95ZF4+aSU2h0O2SgbS5L1Wrbm1 Qygdr9OVyxCwpLkv9Sz4GBrdvX0vmfWidU1nUcQ+FO/+7rQJIXcfCldXKpd/7kRSWCXm 6tWqhd+adwbZsieBra6OTsd7jD8MSLE/UtapRYEe2TY8LqTsNpyt3AhRhIFQGRQ69H5c yzRikCBldy+4Syot7WqZLQCrjI39VN7TBHx8c8YVwzyRIqJjNLDPBLJub6bkCLlW/wDU DZcA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si1810886ejc.303.2021.05.20.01.49.11; Thu, 20 May 2021 01:49:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbhETIb6 (ORCPT + 99 others); Thu, 20 May 2021 04:31:58 -0400 Received: from mga11.intel.com ([192.55.52.93]:61362 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbhETIb5 (ORCPT ); Thu, 20 May 2021 04:31:57 -0400 IronPort-SDR: vDetwh9YCVHRbtdHpyoEC15OLU87RMFxO22+nmyQrs4Ybp+BcS+N1mvVP1olgyIz7qDGIutNUu wWj5LCH5pSfg== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="198088166" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="198088166" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 01:30:15 -0700 IronPort-SDR: v1wQCbBUT3aWfY0Cm3DhdLDmQJeIfEP4e3JYnUQnAfONRhH6N0bAgFZR9Rf8qDZqRAEcFnXKim bL2UVqCIHMow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="473899320" Received: from shbuild999.sh.intel.com ([10.239.147.94]) by orsmga001.jf.intel.com with ESMTP; 20 May 2021 01:30:09 -0700 From: Feng Tang To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko Cc: Andrea Arcangeli , David Rientjes , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Dave Hansen , Ben Widawsky , Andi Kleen , Dan Williams , ying.huang@intel.com, Feng Tang Subject: [RFC Patch v2 1/4] mm/mempolicy: skip nodemask intersect check for 'interleave' when oom Date: Thu, 20 May 2021 16:30:01 +0800 Message-Id: <1621499404-67756-2-git-send-email-feng.tang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1621499404-67756-1-git-send-email-feng.tang@intel.com> References: <1621499404-67756-1-git-send-email-feng.tang@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mempolicy_nodemask_intersects() is used in oom case to check if a task may have memory allocated on some memory nodes. MPOL_INTERLEAVE has set a nodemask, which is not a forced requirement, but just a hint for chosing a node to allocate memory from, and the task may have memory allocated on other nodes than this nodemask. So skip the check. Suggested-by: Michal Hocko Signed-off-by: Feng Tang --- mm/mempolicy.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d79fa29..1964cca 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2098,7 +2098,7 @@ bool init_nodemask_of_mempolicy(nodemask_t *mask) * * If tsk's mempolicy is "default" [NULL], return 'true' to indicate default * policy. Otherwise, check for intersection between mask and the policy - * nodemask for 'bind' or 'interleave' policy. For 'preferred' or 'local' + * nodemask for 'bind' policy. For 'interleave', 'preferred' or 'local' * policy, always return true since it may allocate elsewhere on fallback. * * Takes task_lock(tsk) to prevent freeing of its mempolicy. @@ -2111,29 +2111,13 @@ bool mempolicy_nodemask_intersects(struct task_struct *tsk, if (!mask) return ret; + task_lock(tsk); mempolicy = tsk->mempolicy; - if (!mempolicy) - goto out; - - switch (mempolicy->mode) { - case MPOL_PREFERRED: - /* - * MPOL_PREFERRED and MPOL_F_LOCAL are only preferred nodes to - * allocate from, they may fallback to other nodes when oom. - * Thus, it's possible for tsk to have allocated memory from - * nodes in mask. - */ - break; - case MPOL_BIND: - case MPOL_INTERLEAVE: + if (mempolicy && mempolicy->mode == MPOL_BIND) ret = nodes_intersects(mempolicy->v.nodes, *mask); - break; - default: - BUG(); - } -out: task_unlock(tsk); + return ret; } -- 2.7.4