Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9619597ybl; Fri, 17 Jan 2020 15:31:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxMVT9xo0ig4P0UY7EpKxgej1yEBpocYO1Qkit5pmGMw7+5n5ZX3eONvtGf8SI5L6D22TWk X-Received: by 2002:a05:6830:158:: with SMTP id j24mr8113678otp.316.1579303901070; Fri, 17 Jan 2020 15:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579303901; cv=none; d=google.com; s=arc-20160816; b=YFWVjFbugMFm93BG4Nd8FFQ2XCtpkUsdE73CrT+h21c/d4fvR2/ok2YQ03bVPkTgP/ LWNgtbmPU96NbXg5aHXvUcjjUzY3hVXdEJdS3Efv/aqapTsVEP3G9fYvpwbgXaJXKZSe RFr/FaKP/wZu5kQmJq2g/o/Ndh90SX9zo1o8pGKXLGeiWLZwnbXBncIhlVCohtG8ZoAn QaDI5s6/fayo3z70EjJiFOLx6w4FlL3CtKR6j656TEhAZ4KJtAUz47kq7NSJ/d90rIRp Na5JMzpFk5z0hqwPv0g6TMQdPlVZnH0Fo+cEjl5LRn5+ov5j7k9WP6wSLSP19MRwlADi nbww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nCCYlDZcNgoml+0c24ZO2L5zKWUXiA9cZ58LrpH144k=; b=MO8g31w0r/p7O09MLN6TEoPSc6YqPujPTZwyTRD4FelMeZwxvOWSp28bytc6xIhfS7 q3cp+/4P06jK++faLEU0h0bzZqXEQTwcz0f0CnTeXVJni1/IcJCx7AuSfHXqpEJ/Ozk9 SFikfVKu9JtuxOdLpnT6QJ0r32Y0cezWnlprZMVUl6dCWs9dcwgRAbgrndEm7VIbnF+Z AO3ioBVfCuqhFtOyjwbFryTXRX6IuUxrY6i8GakKEqhnqFlmHaL+ddMYmNpOXbPoVPCN //SOCk01LfQbVkTb8ib0NWdi1eRWQqDeGUQVOwiy/1owL1e2wr0khGurZNHq13gj/ekz iWFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JmbDAwbX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w196si14503824oia.135.2020.01.17.15.31.28; Fri, 17 Jan 2020 15:31:41 -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=@gmail.com header.s=20161025 header.b=JmbDAwbX; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730223AbgAQXae (ORCPT + 99 others); Fri, 17 Jan 2020 18:30:34 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:32866 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbgAQXad (ORCPT ); Fri, 17 Jan 2020 18:30:33 -0500 Received: by mail-ed1-f68.google.com with SMTP id r21so23862621edq.0 for ; Fri, 17 Jan 2020 15:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nCCYlDZcNgoml+0c24ZO2L5zKWUXiA9cZ58LrpH144k=; b=JmbDAwbXXB5RGvmeRg1WWAAKeyjsZZBtJ08W4tZoEk/CSrnPguZJgGe2lioXMXhfBL DCgGnk7oH10mqvkcDu5pSs5RGo0HXJ41X+4w2Zyw2HzVoy28e9v2ArnZUYbZa1qfh0n2 X+b79T707SNPzogQ9MC8LHjmEuIZAvSTjKpKFd4UFOJG/m0fiw8W707oUNKKqGHzMNzB 8Dt/aZeQ8u+LZ1zaemJmg4kn5PYxYeJ88m7bq6i+dg5TNdaoYaLY8jV1ZCutWGZ4r9+f v3iTWfxX/ovKWcAgvz669ECNXk90D2lMcAj7Md8GQWG8kdfVvjkvmCvMp04vho3Hii4g jeVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nCCYlDZcNgoml+0c24ZO2L5zKWUXiA9cZ58LrpH144k=; b=naGmFj1b5EdRpJhNkUy/jvAk3t/+7hHj119LCZ2BBjmcSd/y5daDiwHOxTPhDpl3Dd RZvsKtnGR97tn1DVdNBjBXugd2TTEBwxEAHuxt/4Ey5/kUmVzfV5Du4nYecu3xG6p3Mr 9EvxPUkhgaIcUvn1b5AWTP5rFu48isVcUBnOv5zfPybiPEPpiAPUJ14uy9ZlSGJOzf0S FM8j3+5nZo5oaLiBpj9DtLAqXx0PbVtzdLnXXHvnVFowhGEqe6csQyTJh9j7k6fQWNtY gewFoGxENhPo8SEA2FtZgjHWgtuxEervdgU3u4zIlyi3vW7PC5SOiSB633HMMrjrVe/b oZjA== X-Gm-Message-State: APjAAAWWqydHk+jPq9Be2vu68EMm4WMHcWigoZBDqAd/sHj/YyxIoJy5 r1z+s+3Le5oy3MjHrtEQaBA4594gSrQbGMqtJzX/3gmV X-Received: by 2002:aa7:de05:: with SMTP id h5mr6553530edv.343.1579303832030; Fri, 17 Jan 2020 15:30:32 -0800 (PST) MIME-Version: 1.0 References: <20200117074534.25324-1-richardw.yang@linux.intel.com> <20200117222740.GB29229@richard> In-Reply-To: <20200117222740.GB29229@richard> From: Yang Shi Date: Fri, 17 Jan 2020 15:30:18 -0800 Message-ID: Subject: Re: [PATCH] mm/migrate.c: also overwrite error when it is bigger than zero To: Wei Yang Cc: Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 17, 2020 at 2:27 PM Wei Yang wrote: > > On Fri, Jan 17, 2020 at 03:45:34PM +0800, Wei Yang wrote: > >If we get here after successfully adding page to list, err would be > >the number of pages in the list. > > > >Current code has two problems: > > > > * on success, 0 is not returned > > * on error, the real error code is not returned > > > > Well, this breaks the user interface. User would receive 1 even the migration > succeed. > > The change is introduced by e0153fc2c760 ("mm: move_pages: return valid node > id in status if the page is already on the target node"). Yes, it may return a value which is > 0. But, it seems do_pages_move() could return > 0 value even before this commit. For example, if I read the code correctly, it would do: If we already have some pages on the queue then add_page_for_migration() return error, then do_move_pages_to_node() is called, but it may return > 0 value (the number of pages that were *not* migrated by migrate_pages()), then the code flow would just jump to "out" and return the value. And, it may happen to be 1. I'm not sure if it breaks the user interface since the behavior has been existed for years, and it looks nobody complains about it. Maybe glibc helps hide it or people just care if it is 0 and the status. > > >Signed-off-by: Wei Yang > >--- > > mm/migrate.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > >diff --git a/mm/migrate.c b/mm/migrate.c > >index 557da996b936..c3ef70de5876 100644 > >--- a/mm/migrate.c > >+++ b/mm/migrate.c > >@@ -1677,7 +1677,7 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, > > err1 = do_move_pages_to_node(mm, &pagelist, current_node); > > if (!err1) > > err1 = store_status(status, start, current_node, i - start); > >- if (!err) > >+ if (err >= 0) > > err = err1; > > out: > > return err; > >-- > >2.17.1 > > -- > Wei Yang > Help you, Help me >