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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 26FF3C33CAA for ; Tue, 21 Jan 2020 08:40:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB76524654 for ; Tue, 21 Jan 2020 08:40:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB76524654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 738326B0006; Tue, 21 Jan 2020 03:40:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E90D6B0007; Tue, 21 Jan 2020 03:40:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D6C46B0008; Tue, 21 Jan 2020 03:40:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 485CC6B0006 for ; Tue, 21 Jan 2020 03:40:44 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id DFDB4181AEF10 for ; Tue, 21 Jan 2020 08:40:43 +0000 (UTC) X-FDA: 76400995566.04.cat73_64dbb3e9b235 X-HE-Tag: cat73_64dbb3e9b235 X-Filterd-Recvd-Size: 5729 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Jan 2020 08:40:43 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id d73so1993842wmd.1 for ; Tue, 21 Jan 2020 00:40:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mlOECQ7CcQkzAwbpkxm8GkUs0tDU/ThJ8gW1i6BlUtI=; b=BGDwqPHI6zOSgipCRNjBRW+RxUYxeWjpNEblt+/VfQYI7iX3Ig05AvmF37x6ZSti/n YjtuH3zhApm/IsykAxC+ytGcvmwuK3Wly3/7K168hC4klJpSNxhlIIvP3mAL/0Vm8U3+ 1Dcvj1eAP4bBJYGYspQVPtqeAt0ZkZlh4qSMELOw0GGkppq+wDt9C1wQxoxwfGnL0qcD m4dqOf0azfJnE43Libf578l91WJ4PYXp2yejXOJajhGprewu07XP9+kW8ZxrTPNe5jRs nj87VHtNg90Xh0LOehl0mnt86iRYQyL74jSAxqzzpkV6dss7IwNVAhyaGZKQniS+JHKH 6y0g== X-Gm-Message-State: APjAAAWUylmSSVsSQd5lDnL1HV50fj0PD634w/0Xgk6BG4g1OMEe1V8S r8RdI65G8LntS7uGS9iOpYw= X-Google-Smtp-Source: APXvYqxmo87LjwWCnCYhoNAvperR/n4gqhmQOwBxDxX5GOh/KMVdsccSINDsGl9fzEDtrfht0x7yYw== X-Received: by 2002:a7b:c8cd:: with SMTP id f13mr3116009wml.18.1579596042020; Tue, 21 Jan 2020 00:40:42 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id q3sm2855681wmc.47.2020.01.21.00.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 00:40:41 -0800 (PST) Date: Tue, 21 Jan 2020 09:40:40 +0100 From: Michal Hocko To: Wei Yang Cc: Yang Shi , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm: move_pages: fix the return value if there are not-migrated pages Message-ID: <20200121084040.GC29276@dhcp22.suse.cz> References: <1579325203-16405-1-git-send-email-yang.shi@linux.alibaba.com> <20200120130624.GD18451@dhcp22.suse.cz> <20200120131744.GE18451@dhcp22.suse.cz> <20200121014416.GC1567@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200121014416.GC1567@richard> 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 Tue 21-01-20 09:44:16, Wei Yang wrote: > On Mon, Jan 20, 2020 at 02:17:44PM +0100, Michal Hocko wrote: > >On Mon 20-01-20 14:06:26, Michal Hocko wrote: > >> On Sat 18-01-20 13:26:43, Yang Shi wrote: > >> > The do_move_pages_to_node() might return > 0 value, the number of pages > >> > that are not migrated, then the value will be returned to userspace > >> > directly. But, move_pages() syscall would just return 0 or errno. So, > >> > we need reset the return value to 0 for such case as what pre-v4.17 did. > >> > >> The patch is wrong. migrate_pages returns the number of pages it > >> _hasn't_ migrated or -errno. Yeah that semantic sucks but... > >> So err != 0 is always an error. Except err > 0 doesn't really provide > >> any useful information to the userspace. I cannot really remember what > >> was the actual behavior before my rework because there were some gotchas > >> hidden there. > > > >OK, so I've double checked. do_move_page_to_node_array would carry the > >error code over to do_pages_move and it would store the status stored > >in the pm array. It contains page_to_nid(page) so the resulting code > >indeed behaves properly before my change and this is a regression. I > > Thanks, I see the change. > > >have a very vague recollection that this has been brought up already. > ><...looks in notes...> > >Found it! The report is > >http://lkml.kernel.org/r/0329efa0984b9b0252ef166abb4498c0795fab36.1535113317.git.jstancek@redhat.com > >and my proposed workaround was http://lkml.kernel.org/r/20180829145537.GZ10223@dhcp22.suse.cz > > Well, the above two links return 404. You are right. They are not archived for some reason. Anyway, the patch I was proposing back then is below: commit cfb88c266b645197135cde2905c2bfc82f6d82a9 Author: Michal Hocko Date: Wed Nov 14 12:19:09 2018 +0100 mm: fix do_pages_move error reporting a49bd4d71637 ("mm, numa: rework do_pages_move") has changed the way how we report error to layers above. As the changelog mentioned the semantic was quite unclear previously because the return 0 could mean both success and failure. The above mentioned commit didn't get all the way down to fix this completely because it doesn't report pages that we even haven't attempted to migrate and therefore we cannot simply say that the semantic is: - err < 0 - errno - err >= 0 number of non-migrated pages. Fixes: a49bd4d71637 ("mm, numa: rework do_pages_move") Signed-off-by: Michal Hocko diff --git a/mm/migrate.c b/mm/migrate.c index f7e4bfdc13b7..aa53ebc523eb 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1615,8 +1615,16 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, goto out_flush; err = do_move_pages_to_node(mm, &pagelist, current_node); - if (err) + if (err) { + /* + * Possitive err means the number of failed pages to + * migrate. Make sure to report the rest of the + * nr_pages is not migrated as well. + */ + if (err > 0) + err += nr_pages - i - 1; goto out; + } if (i > start) { err = store_status(status, start, current_node, i - start); if (err) -- Michal Hocko SUSE Labs