From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B358C35242 for ; Fri, 24 Jan 2020 23:20:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 383492087E for ; Fri, 24 Jan 2020 23:20:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 383492087E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B80326B0003; Fri, 24 Jan 2020 18:20:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B30C76B0007; Fri, 24 Jan 2020 18:20:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A50336B0003; Fri, 24 Jan 2020 18:20:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 8F13E6B0003 for ; Fri, 24 Jan 2020 18:20:47 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 555E5180AD807 for ; Fri, 24 Jan 2020 23:20:47 +0000 (UTC) X-FDA: 76414099734.02.plant27_6cab52d23a5e X-HE-Tag: plant27_6cab52d23a5e X-Filterd-Recvd-Size: 8877 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jan 2020 23:20:46 +0000 (UTC) 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; 24 Jan 2020 15:20:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,359,1574150400"; d="scan'208";a="428444178" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 24 Jan 2020 15:20:44 -0800 Date: Sat, 25 Jan 2020 07:20:55 +0800 From: Wei Yang To: Yang Shi Cc: Wei Yang , Michal Hocko , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [v2 PATCH] mm: move_pages: report the number of non-attempted pages Message-ID: <20200124232055.GB16638@richard> Reply-To: Wei Yang References: <1579736331-85494-1-git-send-email-yang.shi@linux.alibaba.com> <20200123032736.GA22196@richard> <20200123085526.GH29276@dhcp22.suse.cz> <20200123225647.GB29851@richard> <20200124064649.GM29276@dhcp22.suse.cz> <20200124152642.GB12509@richard> <9aa3ff03-8397-4ca9-dc55-d893948f7ece@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <9aa3ff03-8397-4ca9-dc55-d893948f7ece@linux.alibaba.com> User-Agent: Mutt/1.9.4 (2018-02-28) Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 24, 2020 at 09:48:30AM -0800, Yang Shi wrote: > > >On 1/24/20 7:26 AM, Wei Yang wrote: >> On Fri, Jan 24, 2020 at 07:46:49AM +0100, Michal Hocko wrote: >> > On Fri 24-01-20 06:56:47, Wei Yang wrote: >> > > On Thu, Jan 23, 2020 at 09:55:26AM +0100, Michal Hocko wrote: >> > > > On Thu 23-01-20 11:27:36, Wei Yang wrote: >> > > > > On Thu, Jan 23, 2020 at 07:38:51AM +0800, Yang Shi wrote: >> > > > > > Since commit a49bd4d71637 ("mm, numa: rework do_pages_move")= , >> > > > > > the semantic of move_pages() was changed to return the numbe= r of >> > > > > > non-migrated pages (failed to migration) and the call would = be aborted >> > > > > > immediately if migrate_pages() returns positive value. But = it didn't >> > > > > > report the number of pages that we even haven't attempted to= migrate. >> > > > > > So, fix it by including non-attempted pages in the return va= lue. >> > > > > >=20 >> > > > > First, we want to change the semantic of move_pages(2). The re= turn value >> > > > > indicates the number of pages we didn't managed to migrate? >> > > > >=20 >> > > > > Second, the return value from migrate_pages() doesn't mean the= number of pages >> > > > > we failed to migrate. For example, one -ENOMEM is returned on = the first page, >> > > > > migrate_pages() would return 1. But actually, no page successf= ully migrated. >> > > > ENOMEM is considered a permanent failure and as such it is retur= ned by >> > > > migrate pages (see goto out). >> > > >=20 >> > > > > Third, even the migrate_pages() return the exact non-migrate p= age, we are not >> > > > > sure those non-migrated pages are at the tail of the list. Bec= ause in the last >> > > > > case in migrate_pages(), it just remove the page from list. It= could be a page >> > > > > in the middle of the list. Then, in userspace, how the return = value be >> > > > > leveraged to determine the valid status? Any page in the list = could be the >> > > > > victim. >> > > > Yes, I was wrong when stating that the caller would know better = which >> > > > status to check. I misremembered the original patch as it was qu= ite some >> > > > time ago. While storing the error code would be possible after s= ome >> > > > massaging of migrate_pages is this really something we deeply ca= re >> > > > about. The caller can achieve the same by initializing the statu= s array >> > > > to a non-node number - e.g. -1 - and check based on that. >> > > >=20 >> > > So for a user, the best practice is to initialize the status array= to -1 and >> > > check each status to see whether the page is migrated successfully= ? >> > Yes IMO. Just consider -errno return value. You have no way to find = out >> > which pages have been migrated until we reached that error. The >> > possitive return value would fall into the same case. >> >=20 >> > > Then do we need to return the number of non-migrated page? What be= nefit could >> > > user get from the number. How about just return an error code to i= ndicate the >> > > failure? I may miss some point, would you mind giving me a hint? >> > This is certainly possible. We can return -EAGAIN if some pages coul= dn't >> > be migrated because they are pinned. But please read my previous ema= il >> > to the very end for arguments why this might cause more problems tha= n it >> > actually solves. >> >=20 >> Let me put your comment here: >>=20 >> Because new users could have started depending on it. It >> is not all that unlikely that the current implementation would ju= st >> work for them because they are migrating a set of pages on to the= same >> node so the batch would be a single list throughout the whole giv= en >> page set. >>=20 >> Your idea is to preserve current semantic, return non-migrated pages n= umber to >> userspace. >>=20 >> And the reason is: >>=20 >> 1. Users have started depending on it. >> 2. No real bug reported yet. >> 3. User always migrate page to the same node. (If my understanding= is >> correct) >>=20 >> I think this gets some reason, since we want to minimize the impact to >> userland. >>=20 >> While let's see what user probably use this syscall. Since from the ma= n page, >> we never told the return value could be positive, the number of non-mi= grated >> pages, user would think only 0 means a successful migration and all ot= her >> cases are failure. Then user probably handle negative and positive ret= urn >> value the same way, like (!err). >>=20 >> If my guess is true, return a negative error value for this case could >> minimize the impact to userland here. >> 1. Preserve the semantic of move_pages(2): 0 means success, negati= ve means >> some error and needs extra handling. >> 2. Trivial change to the man page. >> 3. Suppose no change to users. >>=20 >> Well, in case I missed your point, sorry about that. > >I think we should compare the new semantic with the old one. With the ol= d >semantic the move_pages() return 0 for both success *and* migration fail= ure. >So, I'm supposed (I don't have any real usecase) the user may do the bel= ow >with the old semantic: >=A0=A0=A0 - Just check if it is failed (ignore migration failure), "!err= " is good >enough.=A0 This usecase is fine as well with the new semantic since migr= ation >failure is also a kind of error cases. >=A0=A0=A0=A0 - Care about migration failure, the user needs traverse all= bits in the >status array. With the new semantic they just need check if "err > 0", i= f >they want to know what specific pages are failed to migrate, then traver= se >the status array (with initialized as -1 as Michal suggested in earlier >email). > >So, with returning errno for migration failure if the userspace wants to= see >if migration is failed, they need do: >=A0=A0=A0 1. Check "!err" >=A0=A0=A0 2. Read errno if #1 returns false >=A0=A0=A0 3. Traverse status array to see how many pages are failed to m= igrate > You are right. I misunderstand the mechanism of error handling on err and errno. >But with the new semantic they just need check if "err > 0", one step is= fine >for the most cases. So I said this approach seems more straightforward t= o the >userspace and makes more sense IMHO. > >> > > > This system call has quite a complex semantic and I am not 100% = sure >> > > > what is the right thing to do here. Maybe we do want to continue= and try >> > > > to migrate as much as possible on non-fatal migration failures a= nd >> > > > accumulate the number of failed pages while doing so. >> > > >=20 >> > > > The main problem is that we can have an academic discussion but >> > > > the primary question is what do actual users want. A lack of rea= l >> > > > bug reports suggests that nobody has actually noticed this. So I >> > > > would rather keep returning the correct number of non-migrated >> > > > pages. Why? Because new users could have started depending on it= . It >> > > > is not all that unlikely that the current implementation would j= ust >> > > > work for them because they are migrating a set of pages on to th= e same >> > > > node so the batch would be a single list throughout the whole gi= ven >> > > > page set. >> > --=20 >> > Michal Hocko >> > SUSE Labs --=20 Wei Yang Help you, Help me