Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1096835ybl; Sat, 18 Jan 2020 18:42:21 -0800 (PST) X-Google-Smtp-Source: APXvYqx3a7iaVQuxxKWL1y8CUqxfJ9dK53iwLRb3IZulfgD3Hay/KfqnLin5qhtscQoP856S60Ep X-Received: by 2002:a54:4396:: with SMTP id u22mr8872484oiv.128.1579401741698; Sat, 18 Jan 2020 18:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579401741; cv=none; d=google.com; s=arc-20160816; b=w2oNAppkJEBm7jLUt2YzFqvl5OFQ/D9F0Njnh2ry0+Fm8o8idfbyhmRVJwW7LE4PPi lEzDeuropnS+3JrRu6O4FbSWYJ+bKWy15/JJjNsQpiGzW5Kh2z6zqRdUlC5FQINJRrzG arsHPYJMPyf2kGNxd1vOGCOdOZ90OAPcYdyCbleiqXkxETbGj/1OCqeXAguP7CoV1yt7 s21rwsU4YdwyRtwNA/3JhEleXqqMfEQL8zDvfieGZSiyCQ6k2pu2HxKYe4YtoQDbCeHE 6i0maDRCc5BC4Ci9Hsh1iQLMXkw2FRIJVjha3MtE6xj2lEINH5OL7zMwkgGOJbqdZGHp Q3dA== 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:reply-to:message-id :subject:cc:to:from:date; bh=LfQTsPxye7NG4C1pPufTbkzfuVdZxEqbYlwb839+dzM=; b=SGKO4qOgtZPRePrFHU+fihKN/JxAwEtLi7RhTgROygET2brzWzIT1o13pMKIhsWF2G BsW+tk4YIxd+hW77VKDA2/AwTzzchOge3au9kb0K1cN3WmQYH3vCKXH1QRsK6gA7/bop gSA8rkehddmSEvp2BQTpM780FhBK45bpMyW2xCeagBo9ZIYVBUswoIvhXpjm8jcuVrqz GINpdKRZ4FrThRZ9uKw33XNQWfcgttFDGIYHqOk9EHitgxQ+tklsezRDVmTRqjVWcjnU emtFifquYqSN9oKxvhTf8MtA7RJqUIv+r5B5J14kESLNpCmEl5vBzubyPIu3d9FdelVb /6FQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si15651287oii.57.2020.01.18.18.42.09; Sat, 18 Jan 2020 18:42:21 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbgASClQ (ORCPT + 99 others); Sat, 18 Jan 2020 21:41:16 -0500 Received: from mga17.intel.com ([192.55.52.151]:5522 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727403AbgASClP (ORCPT ); Sat, 18 Jan 2020 21:41:15 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2020 18:41:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,336,1574150400"; d="scan'208";a="426401963" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 18 Jan 2020 18:41:13 -0800 Date: Sun, 19 Jan 2020 10:41:24 +0800 From: Wei Yang To: Yang Shi Cc: Wei Yang , Andrew Morton , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH] mm/migrate.c: also overwrite error when it is bigger than zero Message-ID: <20200119024124.GF9745@richard> Reply-To: Wei Yang References: <20200117074534.25324-1-richardw.yang@linux.intel.com> <20200117222740.GB29229@richard> <20200117234829.GA2844@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) 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 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. -- Wei Yang Help you, Help me