Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2548814ybl; Mon, 20 Jan 2020 05:07:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyQEP9bHQnePzntC0gKhMKGR8mEA2Yx6cNCvVTk4m5NgpKhf2WpnxWiMW2npPVYIKjoyza+ X-Received: by 2002:a9d:68cc:: with SMTP id i12mr15793465oto.207.1579525670371; Mon, 20 Jan 2020 05:07:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579525670; cv=none; d=google.com; s=arc-20160816; b=DMgv3T9ShoKp+g+3HFPKwExv1r0GU8QPHSSBSfpKJimV8pa/k3CXIhefzKDlDgGUxb KeCiKjw7qBQSDjmgR2zj7bdQNCa64ejMExKyDwdBNdCoVbZnmArDH+xt1lCnwWuZpLlR Ya1wcAKwi4VSXuHDFd1skJHFqtce+RXlK1ZSwNhKzeZKzknL3YdAZXJCwCHkDh/tBCdd iCa1HiqNKC1Gs8ICXHJknrkHwi3+zI/DmSCd2gaR48ooL+rprZ3cccdT6PgVQOf0HCP3 yqKg4bApiEygC5mBv6dPBp28JBpMmgSOli1NEcZ2gIEZd3Ypsun+NSypwn4jC3ii8fyb fw5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yAP4AxE8jezFjjNwotXQWmTcKA84LGA03EpyU82A5NQ=; b=RCPmfyHsAqVFvo2SHDE4dGTWm+iF7FUNynqJvPIQp2z+09DtHXzPnzB3sP22aljRxb e/QhrOSPzD1bQh83JmsqGf39GHQY3CXPJyM9jOcAuYow6vFgOLbWt9mGJkZk99qiNkta hUxwmj9mDFpKwaFZCf6zYL4JqdbTs6shxIrmIR37cFETQMev/2/jvnil2sN90R0pYdcx ykv9o4OTzaXhB4XZRBxm19vTwbsx6Kd5AYIMXJh6dOVnrbrAy+jdLNPT1EB52cHzORWB NS9DSO5NXBpmPobo7nK+7NR2+gsQzEooBXLkeTIyJ8M1dJyjAbu0Q7xEWGe6DsRD83Mo S22Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si19042505otc.228.2020.01.20.05.07.37; Mon, 20 Jan 2020 05:07:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbgATNG3 (ORCPT + 99 others); Mon, 20 Jan 2020 08:06:29 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36168 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgATNG3 (ORCPT ); Mon, 20 Jan 2020 08:06:29 -0500 Received: by mail-wm1-f68.google.com with SMTP id p17so14662913wma.1; Mon, 20 Jan 2020 05:06:27 -0800 (PST) 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yAP4AxE8jezFjjNwotXQWmTcKA84LGA03EpyU82A5NQ=; b=JFQt4NA9ODEdbrhgqEnltqJvRrqhvFTw6q548TRUBfPZbxeV/NGixFVZHipaxPFn2R PfshJIod+7e3W3xcMHzNt+N59SITEe/EbaKu4lmCqZ/D6IDD1KcIMB/uIREOuxpAivLJ s6OSGP7hKkVU7ImbGWNyWPu8KyNKxV1waHyl/tSvQteXViGSCZAOGyW2PkJ1MceMRogF TOpKj5GfTn5gVcH3xj9uMtIOHHma26n+Zd/gJwDZ+DWs65LpTsTuJuEz+MdSjwfuSz22 ga1rYipaN2UQEiuEZA08sr6SR6j5eI0xxSxPn2++JjeqCGrOhv1ozuryiU1U52pD6kaI mZKg== X-Gm-Message-State: APjAAAUBHHU/cHq2FqddxOp5TTo21KmOlVI9Q6L1g19JY9VV5e2pqARL 54XeCGvTciiKJJNdOworKS8cV9Rl X-Received: by 2002:a05:600c:22d3:: with SMTP id 19mr18745263wmg.20.1579525586658; Mon, 20 Jan 2020 05:06:26 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id c195sm3106848wmd.45.2020.01.20.05.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 05:06:25 -0800 (PST) Date: Mon, 20 Jan 2020 14:06:24 +0100 From: Michal Hocko To: Yang Shi Cc: richardw.yang@linux.intel.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm: move_pages: fix the return value if there are not-migrated pages Message-ID: <20200120130624.GD18451@dhcp22.suse.cz> References: <1579325203-16405-1-git-send-email-yang.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1579325203-16405-1-git-send-email-yang.shi@linux.alibaba.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 18-01-20 13:26:43, Yang Shi wrote: > The do_move_pages_to_node() might return > 0 value, the number of pages > that are not migrated, then the value will be returned to userspace > directly. But, move_pages() syscall would just return 0 or errno. So, > we need reset the return value to 0 for such case as what pre-v4.17 did. The patch is wrong. migrate_pages returns the number of pages it _hasn't_ migrated or -errno. Yeah that semantic sucks but... So err != 0 is always an error. Except err > 0 doesn't really provide any useful information to the userspace. I cannot really remember what was the actual behavior before my rework because there were some gotchas hidden there. If you want to fix this properly then you have to query node status of each page unmigrated when migrate_pages fails with > 0. This would be easier if the fix is done on the latest cleanup posted to the list which consolidates all do_move_pages_to_node and store_status calls to a single function. > Fixes: a49bd4d71637 ("mm, numa: rework do_pages_move") > Cc: Michal Hocko > Cc: Wei Yang > Cc: [4.17+] > Signed-off-by: Yang Shi > --- > mm/migrate.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 86873b6..3e75432 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1659,8 +1659,11 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, > goto out_flush; > > err = do_move_pages_to_node(mm, &pagelist, current_node); > - if (err) > + if (err) { > + if (err > 0) > + err = 0; > goto out; > + } > if (i > start) { > err = store_status(status, start, current_node, i - start); > if (err) > -- > 1.8.3.1 -- Michal Hocko SUSE Labs