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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56A49C001B0 for ; Mon, 7 Aug 2023 13:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B612E8D0005; Mon, 7 Aug 2023 09:07:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B11AF8D0002; Mon, 7 Aug 2023 09:07:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D8F28D0005; Mon, 7 Aug 2023 09:07:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8B4038D0002 for ; Mon, 7 Aug 2023 09:07:05 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3968D80A92 for ; Mon, 7 Aug 2023 13:07:05 +0000 (UTC) X-FDA: 81097334010.04.EE5D50B Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf30.hostedemail.com (Postfix) with ESMTP id 1A91780010 for ; Mon, 7 Aug 2023 13:07:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Rd9o/ypz"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691413623; a=rsa-sha256; cv=none; b=GWxnNUsvCpusIMDn71R4knFjc2mpCBGB/IXLN9D605acgOPATxgzQCCIZtdzJjnXQUjBNz VyOMOnsenBSPtVcBjkO6wpXG8biJMva+ovez5MztaaGB8zYt4DAKCpJHpqd6t9Et0GqrM2 2GsbJuWqyJfdddp5Hfj3sTDaijkUIL0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Rd9o/ypz"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691413623; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xI3S2WaKzNocXh6ej+7CMiKcLHrWdjS9T07YC0W5so4=; b=JRirREAn/fXt+5XGMBtE1ZjEuhzvjCAyn9VOIBFgIBX9/9T1ThwpZrQE1jhw7fpZwPWKMJ UqdJyHcQk2WB/mGhviN2PDARvM4dJrl7/9JsrRw09jSVkP6g/6ezkGt5khd5bHCGLakFzy yQcoFIWFalejnWMi/hnvtyULJv7WdYY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8E4761FDAE; Mon, 7 Aug 2023 13:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1691413621; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xI3S2WaKzNocXh6ej+7CMiKcLHrWdjS9T07YC0W5so4=; b=Rd9o/ypzL+Wy4brzEeOhDUk4/3W6XWJMRGg1+lW461w3pfHTBeAewCHfa/hWQB1NpXCBXL iMLqntzSkaII2RoOHd/3QSoWmPgFlFbhgan4Mjm9duFaLMYEi0CM8w2BvFdcqUqiPxkxFp bWebMYDZod+QqcZi7EEnwKKxJFZF+c4= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7007B13487; Mon, 7 Aug 2023 13:07:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iSlYGHXs0GQ6EgAAMHmgww (envelope-from ); Mon, 07 Aug 2023 13:07:01 +0000 Date: Mon, 7 Aug 2023 15:07:00 +0200 From: Michal Hocko To: Alistair Popple Cc: Andrew Morton , linux-mm@kvack.org, jhubbard@nvidia.com, ying.huang@intel.com, osalvador@suse.de, baolin.wang@linux.alibaba.com, ziy@nvidia.com, shy828301@gmail.com, ryan.roberts@arm.com Subject: Re: [PATCH 1/2] mm/migrate.c: Fix return code when migration fails Message-ID: References: <20230807063945.911582-1-apopple@nvidia.com> <87pm3z2fer.fsf@nvdebian.thelocal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pm3z2fer.fsf@nvdebian.thelocal> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1A91780010 X-Stat-Signature: w7y75iqkk1ryhk45amw5m4fa1j5knpyr X-HE-Tag: 1691413622-992091 X-HE-Meta: U2FsdGVkX1+eHq79hxxpQbwwkMHft2vut9PWI73aL0GgPG5qye0w2ha8cri3TRWd90UzXh//ghip4dpewvPLIlt+cvsdWMNEUcW7taEXnTBheSBbbrSUgV/5HkQbZHAgS+W3HdkvpgoJh4mLliJtC9iFXkeDNJZcvWJeEaY/VCn3/HWUnQZExOL5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ilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 07-08-23 22:31:52, Alistair Popple wrote: > > Michal Hocko writes: > > > On Mon 07-08-23 16:39:44, Alistair Popple wrote: > >> When a page fails to migrate move_pages() returns the error code in a > >> per-page array of status values. The function call itself is also > >> supposed to return a summary error code indicating that a failure > >> occurred. > >> > >> This doesn't always happen. Instead success can be returned even > >> though some pages failed to migrate. This is due to incorrectly > >> returning the error code from store_status() rather than the code from > >> add_page_for_migration. Fix this by only returning an error from > >> store_status() if the store actually failed. > > > > Error reporting by this syscall has been really far from > > straightforward. Please read through a49bd4d71637 and the section "On a > > side note". > > Is there any specific reason you are trying to address this now or is > > this motivated by the code inspection? > > Thanks Michal. There was no specific reason to address this now other > than I came across this behaviour when updating the migration selftest > to inspect the status array and thought it was odd. I was seeing pages > had failed to migrate according to the status argument even though > move_pages() had returned 0 (ie. success) rather than a number of > non-migrated pages. It is good to mention such a motivation in the changelog to make it clear. Also do we have a specific test case which trigger this case? > If I'm interpreting the side note correctly the behaviour you were > concerned about was the opposite - returning a fail return code from > move_pages() but not indicating failure in the status array. > > That said I'm happy to leave the behaviour as is, although in that case > an update to the man page is in order to clarify a return value of 0 > from move_pages() doesn't actually mean all pages were successfully > migrated. While I would say that it is better to let old dogs sleep I do not mind changing the behavior and see whether anything breaks. I suspect nobody except for couple of test cases hardcoded to the original behavior will notice. > >> Signed-off-by: Alistair Popple > >> Fixes: a49bd4d71637 ("mm, numa: rework do_pages_move") The patch itself looks good. I am not sure the fixes tag is accurate. Has the reporting been correct before this change? I didn't have time to re-read the original code which was quite different. Anyway Acked-by: Michal Hocko Anyway rewriting this function to clarify the error handling would be a nice exercise if somebody is interested. > >> --- > >> mm/migrate.c | 4 +++- > >> 1 file changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/migrate.c b/mm/migrate.c > >> index 24baad2571e3..bb3a37245e13 100644 > >> --- a/mm/migrate.c > >> +++ b/mm/migrate.c > >> @@ -2222,7 +2222,9 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, > >> * If the page is already on the target node (!err), store the > >> * node, otherwise, store the err. > >> */ > >> - err = store_status(status, i, err ? : current_node, 1); > >> + err1 = store_status(status, i, err ? : current_node, 1); > >> + if (err1) > >> + err = err1; > >> if (err) > >> goto out_flush; > >> > >> -- > >> 2.39.2 -- Michal Hocko SUSE Labs