Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3052555ybi; Tue, 2 Jul 2019 01:11:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBtXWelIg90sHxcmnwGgk60MR+zyNezWUh83TRzM4vtxlHlBwwNGF3bWtYPXZWYZHMzOQV X-Received: by 2002:a17:90a:37e9:: with SMTP id v96mr4075831pjb.10.1562055107463; Tue, 02 Jul 2019 01:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055107; cv=none; d=google.com; s=arc-20160816; b=VLSgdIr15so2dniJjCKlOZROKPSpweTtI4ZbLEF3HQN9jpu1KfYQ+Uchv2AseJT0GU hlDV9px3kKxfC6XFl2hQKxPJYrhoqa1gEKMNs7nvm78IiM8BltDVM77+g03KLtfWTNNi eIpk90BVnHP7mitS/heQ12QLnWTfQSfhx0XxsmTE/s6X/xRhaYJYWSpKSfg0G4m5uuls Yzyud0ErXjfU4g23b1Vp7CEiVNuIvjWl8s2FPeA7ghEfKFu/WU/btP4jXwASQ9yvwU9O q0OTn86PNe48lVIUlzt+dJuJ3ZmO7sXIEpOG0ZAbW2BO2rY/Uy7bFLmWyYN1VVit+mGG NxuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M1PK9iHa8zQgo6DJ19KkTbdZasNv8/SP/tW9tbUba4g=; b=iCVUGYBJHPrqVNjBdzf9u48UWK14QdWIzMKHjWW3egEP7xW32Nei1/6Vx/jzCiVEWJ 7Bj35jATTnD7Kbwv7bhjq1jQ3a42/m1dvLPYDM+SzGHfXd4k+qqUw+UDHVkS9uYveGKN /UyKS7bg9HnNc0W0cu8/IjAlKzhLbx0GiBsmN+3nRFNgIBXvIGV64vrKYKbh5ZpdPXqc fF6pXYp1VVjHonobisdHjvNBCXxjRqtRJBrt3LP2qlEdODB8a9vmKwcfNpgQlSOq5Aq/ evk3EnkcF8neyflkgGOeDXyAWPwsUBMuWv9a5P9tCb5Tcr8mON0/6Wf5Y+1azv/L2bAV qAIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GnExBPo8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si14546783pfr.86.2019.07.02.01.11.32; Tue, 02 Jul 2019 01:11:47 -0700 (PDT) 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=@kernel.org header.s=default header.b=GnExBPo8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728618AbfGBIJO (ORCPT + 99 others); Tue, 2 Jul 2019 04:09:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:57004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728584AbfGBIJN (ORCPT ); Tue, 2 Jul 2019 04:09:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC2BB2064A; Tue, 2 Jul 2019 08:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054952; bh=2LdyCcp7vywEHF9IXR3k4aLZAexHz8GDEeExy0nYW1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnExBPo8JaL/sAHounBYvimuomgdaJKwyrfBXQM4mm22TQqwV8kA7gligRbeK6ff5 MrUIeS1jEu3m2s65oISGS+8qSg1HmM14vLaxdCNWDzRq3OCHXt325Q8g7T/EIjGDS0 W36O7yJ88FCPELZGQX0Ql7WOFr7tjSSysgOpPcR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zhong jiang , Vlastimil Babka , Oscar Salvador , Anshuman Khandual , Michal Hocko , Mel Gorman , Andrea Arcangeli , Ralph Campbell , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 17/43] mm/mempolicy.c: fix an incorrect rebind node in mpol_rebind_nodemask Date: Tue, 2 Jul 2019 10:01:57 +0200 Message-Id: <20190702080124.674463671@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080123.904399496@linuxfoundation.org> References: <20190702080123.904399496@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: zhong jiang commit 29b190fa774dd1b72a1a6f19687d55dc72ea83be upstream. mpol_rebind_nodemask() is called for MPOL_BIND and MPOL_INTERLEAVE mempoclicies when the tasks's cpuset's mems_allowed changes. For policies created without MPOL_F_STATIC_NODES or MPOL_F_RELATIVE_NODES, it works by remapping the policy's allowed nodes (stored in v.nodes) using the previous value of mems_allowed (stored in w.cpuset_mems_allowed) as the domain of map and the new mems_allowed (passed as nodes) as the range of the map (see the comment of bitmap_remap() for details). The result of remapping is stored back as policy's nodemask in v.nodes, and the new value of mems_allowed should be stored in w.cpuset_mems_allowed to facilitate the next rebind, if it happens. However, 213980c0f23b ("mm, mempolicy: simplify rebinding mempolicies when updating cpusets") introduced a bug where the result of remapping is stored in w.cpuset_mems_allowed instead. Thus, a mempolicy's allowed nodes can evolve in an unexpected way after a series of rebinding due to cpuset mems_allowed changes, possibly binding to a wrong node or a smaller number of nodes which may e.g. overload them. This patch fixes the bug so rebinding again works as intended. [vbabka@suse.cz: new changlog] Link: http://lkml.kernel.org/r/ef6a69c6-c052-b067-8f2c-9d615c619bb9@suse.cz Link: http://lkml.kernel.org/r/1558768043-23184-1-git-send-email-zhongjiang@huawei.com Fixes: 213980c0f23b ("mm, mempolicy: simplify rebinding mempolicies when updating cpusets") Signed-off-by: zhong jiang Reviewed-by: Vlastimil Babka Cc: Oscar Salvador Cc: Anshuman Khandual Cc: Michal Hocko Cc: Mel Gorman Cc: Andrea Arcangeli Cc: Ralph Campbell Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -305,7 +305,7 @@ static void mpol_rebind_nodemask(struct else { nodes_remap(tmp, pol->v.nodes,pol->w.cpuset_mems_allowed, *nodes); - pol->w.cpuset_mems_allowed = tmp; + pol->w.cpuset_mems_allowed = *nodes; } if (nodes_empty(tmp))