Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1223625ybl; Sat, 18 Jan 2020 21:57:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxDXMpJitCGf+qOqvgzYCuQPJx8frnfVAyBznTaDhz6jNud2Z7Vme8ozNp2MP09kQVgWWje X-Received: by 2002:a9d:7dc9:: with SMTP id k9mr11804676otn.117.1579413430570; Sat, 18 Jan 2020 21:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579413430; cv=none; d=google.com; s=arc-20160816; b=bDAHbOW+t9BM9q4SQoTy1i0nJcU84onuy9KF/U9hrO+M5b14Q8Vp8D3NmSF/4Z+mS+ IwoETA4zpEyM+nLstDtjj00WVWUScxt2N8VTAwg3whuOr5kxapdQj4I2PpJgUM8agMm1 rFW5wXiv5zuhOOVu3zkYEajIDDZa0vJmVf5FQ+VRupviEphQg+u3YY11zXDUPVuDQf9G hpb7xdYbbwj+DBo09el6YceHVs9o709JL6szhtwu5SJBcWiRaLANsQVfqOO7uijOxtiT rOY2DvgeuE4XxITar63SeogtdJvwAIBZ70s6TCQiZU7HZ00HzL5C3wTtoIbn+nN8aUbj JnHg== 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=3nHzkoKmcJ0xoUEz4Emp960Em7r3GKffoU1aogBN2B4=; b=Uc9N9w9YS7syudLwBETzIX9jhWzVPMEvdmxGb5s/cOq+eG+Mq+K2VEhiebxzQBsH4L up2EP4rG1pOszyED4lQ/mcNTuYaWuWxT7UFJWWbl7TZg1n8bkZ881bgqgzDUUMZdWHIi m9HYb6zYwGSK7yRRDv6Xy9KV0I6NA/AGi8NX8xtwTUlLt1pxMkd45jRlLGXWrxULdJqN EkmokQUEbgc/aogWJc6cQl4z+zbBryxaqMPnxn5tCFK7jWLtmj3xcYt5/Et4/NJDcwUC VqOqzm3QjjGgmgczcRCCu9DsvFnbWJ0/PIe8KQYX8QKPAr0ah6v0nth5i8tfcvXZ+W/J IsmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lphl8NYR; 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 w16si16481996oih.154.2020.01.18.21.56.51; Sat, 18 Jan 2020 21:57:10 -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=lphl8NYR; 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 S1726421AbgASFzH (ORCPT + 99 others); Sun, 19 Jan 2020 00:55:07 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:34305 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbgASFzH (ORCPT ); Sun, 19 Jan 2020 00:55:07 -0500 Received: by mail-ed1-f68.google.com with SMTP id l8so26398293edw.1 for ; Sat, 18 Jan 2020 21:55:06 -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=3nHzkoKmcJ0xoUEz4Emp960Em7r3GKffoU1aogBN2B4=; b=lphl8NYRco23VhEHouePv/vd0G8tEh9WzrzuzOwVD2qjBnDLMvpZayvheDCG+k7d7I 8I31tDt6IxlVKSv58QeNqBYP+AxDQnaRnwIO6wdI4G17iuYOY3/Rf/utZ2JcgXY9UVHq 3BsZaj5R8jT0kjs10fx+2yQmziBoFhb2xaH8gbygPaYPMMhnltB6TCudwL+dgxhCiIr8 amFsTICObqTtcLb2sGfoRuIsFxsjqgPfw1xcMIOCJNkF4PU3mAU1bCP0KazCrK8ENI3E cbWBCMBdR3jqZl2X/9lbgt9fiLr8V+Mj2db9A6sSom2mTvSSIoInt6MNwWVSXkiWWMV0 vn8A== 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=3nHzkoKmcJ0xoUEz4Emp960Em7r3GKffoU1aogBN2B4=; b=e1txTSt8r8za1I+s1KARjV6C9527h5YSa9LeXyrwu1boH9AgPkVfeKB4w8ceNuEqPL KvAyzNB2T+oYy8Zv/Y7c7xG9Ww0gLPfugbnQcxehSJatEmd34MNmi1IVWZQgMmJzlgc+ vDKsZdMraOAnJdx/MWS3DHJI62prL8/ihU6ERBDOaZSw3mhZuHeRcPt+bSQRcOK7y/+E 0If196Ca8tm2P2CuuWxBZyRbSkS9flf5WQ1gwSo39wG7TlCgY2+MAcizdrEh0CL2I2zH Z71HusXQMf8Xp9hax3NJUH6kA7ISBiriWfk0XbZhw1/QkZcDwmIHXttktFXzvHBrhTOl SNSA== X-Gm-Message-State: APjAAAXYT8xCzNKKxHPrmUornvbQqppc8x+GmRfHzMBh+puGqAHMxhPF zShROw1FDhc3g9/+Ro7+jdZyfTuEfOJ3xbHD/uve7A== X-Received: by 2002:a05:6402:30ba:: with SMTP id df26mr11374806edb.256.1579413305371; Sat, 18 Jan 2020 21:55:05 -0800 (PST) MIME-Version: 1.0 References: <20200117074534.25324-1-richardw.yang@linux.intel.com> <20200117222740.GB29229@richard> <20200117234829.GA2844@richard> <20200119024124.GF9745@richard> In-Reply-To: <20200119024124.GF9745@richard> From: Yang Shi Date: Sat, 18 Jan 2020 21:54:50 -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 Sat, Jan 18, 2020 at 6:41 PM Wei Yang wrote: > > On Fri, Jan 17, 2020 at 08:56:27PM -0800, Yang Shi wrote: > >On Fri, Jan 17, 2020 at 3:48 PM Wei Yang wrote: > >> > >> On Fri, Jan 17, 2020 at 03:30:18PM -0800, Yang Shi wrote: > >> >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. > >> > > >> > >> This is another point I think current code is not working well. And actually, > >> the behavior is not well defined or our kernel is broken for a while. > > > >Yes, we already spotted a few mismatches, inconsistencies and edge > >cases in these NUMA APIs. > > > >> > >> When you look at the man page, it says: > >> > >> RETURN VALUE > >> On success move_pages() returns zero. On error, it returns -1, and sets errno to indicate the error > >> > >> So per my understanding, the design is to return -1 on error instead of the > >> pages not managed to move. > > > >So do I. > > > >> > >> For the user interface, if original code check 0 for success, your change > >> breaks it. Because your code would return 1 instead of 0. Suppose most user > >> just read the man page for programming instead of reading the kernel source > >> code. I believe we need to fix it. > > > >Yes, I definitely agree we need fix it. But the commit log looks > >confusing, particularly "on error, the real error code is not > >returned". If the error is returned by add_page_for_migration() then > >it will not be returned to userspace instead of reporting via status. > >Do you mean this? > > > > Sorry for the confusion. > > Here I mean, if add_page_for_migratioin() return 1, and the following err1 > from do_move_pages_to_node() is set, the err1 is not returned. > > The reason is err is not 0 at this point. Yes, I see your point. Please elaborate this in the commit log. > > -- > Wei Yang > Help you, Help me