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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,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 79557C2D0DB for ; Fri, 24 Jan 2020 17:48:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A08E2071A for ; Fri, 24 Jan 2020 17:48:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A08E2071A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 85AEA6B0005; Fri, 24 Jan 2020 12:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80AFB6B0006; Fri, 24 Jan 2020 12:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 721D16B0007; Fri, 24 Jan 2020 12:48:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 56C2A6B0005 for ; Fri, 24 Jan 2020 12:48:47 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id DF8D7441A for ; Fri, 24 Jan 2020 17:48:46 +0000 (UTC) X-FDA: 76413263052.24.story75_124915ecbc633 X-HE-Tag: story75_124915ecbc633 X-Filterd-Recvd-Size: 8301 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jan 2020 17:48:42 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0ToSpJP6_1579888114; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0ToSpJP6_1579888114) by smtp.aliyun-inc.com(127.0.0.1); Sat, 25 Jan 2020 01:48:37 +0800 Subject: Re: [v2 PATCH] mm: move_pages: report the number of non-attempted pages To: Wei Yang , Michal Hocko Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org 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> From: Yang Shi Message-ID: <9aa3ff03-8397-4ca9-dc55-d893948f7ece@linux.alibaba.com> Date: Fri, 24 Jan 2020 09:48:30 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20200124152642.GB12509@richard> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US 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 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 number of >>>>>> non-migrated pages (failed to migration) and the call would be abo= rted >>>>>> immediately if migrate_pages() returns positive value. But it did= n't >>>>>> report the number of pages that we even haven't attempted to migra= te. >>>>>> So, fix it by including non-attempted pages in the return value. >>>>>> >>>>> First, we want to change the semantic of move_pages(2). The return = value >>>>> indicates the number of pages we didn't managed to migrate? >>>>> >>>>> Second, the return value from migrate_pages() doesn't mean the numb= er of pages >>>>> we failed to migrate. For example, one -ENOMEM is returned on the f= irst page, >>>>> migrate_pages() would return 1. But actually, no page successfully = migrated. >>>> ENOMEM is considered a permanent failure and as such it is returned = by >>>> migrate pages (see goto out). >>>> >>>>> Third, even the migrate_pages() return the exact non-migrate page, = we are not >>>>> sure those non-migrated pages are at the tail of the list. Because = in the last >>>>> case in migrate_pages(), it just remove the page from list. It coul= d 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 whic= h >>>> status to check. I misremembered the original patch as it was quite = some >>>> time ago. While storing the error code would be possible after some >>>> massaging of migrate_pages is this really something we deeply care >>>> about. The caller can achieve the same by initializing the status ar= ray >>>> to a non-node number - e.g. -1 - and check based on that. >>>> >>> 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 ou= t >> which pages have been migrated until we reached that error. The >> possitive return value would fall into the same case. >> >>> Then do we need to return the number of non-migrated page? What benef= it could >>> user get from the number. How about just return an error code to indi= cate 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 couldn= 't >> be migrated because they are pinned. But please read my previous email >> to the very end for arguments why this might cause more problems than = it >> actually solves. >> > Let me put your comment here: > > Because new users could have started depending on it. It > is not all that unlikely that the current implementation would jus= t > 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 give= n > page set. > > Your idea is to preserve current semantic, return non-migrated pages nu= mber to > userspace. > > And the reason is: > > 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) > > I think this gets some reason, since we want to minimize the impact to > userland. > > While let's see what user probably use this syscall. Since from the man= page, > we never told the return value could be positive, the number of non-mig= rated > pages, user would think only 0 means a successful migration and all oth= er > cases are failure. Then user probably handle negative and positive retu= rn > value the same way, like (!err). > > 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, negativ= e means > some error and needs extra handling. > 2. Trivial change to the man page. > 3. Suppose no change to users. > > Well, in case I missed your point, sorry about that. I think we should compare the new semantic with the old one. With the=20 old semantic the move_pages() return 0 for both success *and* migration=20 failure. So, I'm supposed (I don't have any real usecase) the user may=20 do the below with the old semantic: =C2=A0=C2=A0=C2=A0 - Just check if it is failed (ignore migration failur= e), "!err" is=20 good enough.=C2=A0 This usecase is fine as well with the new semantic sin= ce=20 migration failure is also a kind of error cases. =C2=A0=C2=A0=C2=A0=C2=A0 - Care about migration failure, the user needs = traverse all bits=20 in the status array. With the new semantic they just need check if "err=20 > 0", if they want to know what specific pages are failed to migrate,=20 then traverse the status array (with initialized as -1 as Michal=20 suggested in earlier email). So, with returning errno for migration failure if the userspace wants to=20 see if migration is failed, they need do: =C2=A0=C2=A0=C2=A0 1. Check "!err" =C2=A0=C2=A0=C2=A0 2. Read errno if #1 returns false =C2=A0=C2=A0=C2=A0 3. Traverse status array to see how many pages are fa= iled to migrate But with the new semantic they just need check if "err > 0", one step is=20 fine for the most cases. So I said this approach seems more=20 straightforward to 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 and >>>> accumulate the number of failed pages while doing so. >>>> >>>> The main problem is that we can have an academic discussion but >>>> the primary question is what do actual users want. A lack of real >>>> 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 just >>>> work for them because they are migrating a set of pages on to the sa= me >>>> node so the batch would be a single list throughout the whole given >>>> page set. >> --=20 >> Michal Hocko >> SUSE Labs