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 9F8C6EED61E for ; Fri, 15 Sep 2023 18:26:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F3086B03A6; Fri, 15 Sep 2023 14:26:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2476B03A7; Fri, 15 Sep 2023 14:26:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06A2E6B03A8; Fri, 15 Sep 2023 14:26:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ED6766B03A6 for ; Fri, 15 Sep 2023 14:26:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AF24C1CA4B8 for ; Fri, 15 Sep 2023 18:26:20 +0000 (UTC) X-FDA: 81239661720.02.C5B2353 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 023BE4000D for ; Fri, 15 Sep 2023 18:26:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="fWK/ibyb"; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694802379; 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=f5vxbstncXGDTYF4k8iBAO/uRU8zJv+hlaWNzlrq5m4=; b=P93xp4P6tHH1CSpgNYnCO+aMFuf2VTOnJEzUaaBD4XfQkWPanXpohvug32eUyqiL2lM8Fl aTKP9YRodPOCpCWvJY07BEIHyxocTEPqanVxEVF7VnNFN1O2O3fudIp9NwG7ZyfE1Q0Alw vk/UIvwPpgmUrY9brM41sgkKsC1nJJU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694802379; a=rsa-sha256; cv=none; b=qfcMGbXGQspb0s0toN9zD1z/3X6FAwzlyy3PNuM0kSilezwlXB88wASobl5ZEpkOow+z7j hwjtncRXeuUBCSLJYl34O/k4juhFYDiAr/25lezp5CCmvb0u59KxqxXtucO4EFYahVkUet d1fRqTNJJz4d7hLLYrnEB6iiY0MzAag= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="fWK/ibyb"; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=f5vxbstncXGDTYF4k8iBAO/uRU8zJv+hlaWNzlrq5m4=; b=fWK/ibyb6ETNzkHlnHyn9gX1RS Fmd7YQNPRUfcacHqJp6y9G+nRfF0x6E75zxeHzf95FBuFmoCiiZe1a3cJDq+Gfm8sreTmj3EajlvQ JF7/jGs0EwsxeHvQyg4ZySBqsCi2XtlteoDCDTl9bGfG2ophERMZ89K++B9Z7YHXlbCXQobz03emV Yy5XRpP3xa/DHm84iSkQcAtBmaAOyjQlyOCrXQuYqLpDROULAcbUJiXNapPCyB6bnhxDndGxG/p7R jie1+97gfLzKQQYMkh3q7MRww2A2G78LL5GQ4xtZ0fHnnHCUBvE+jJZawlNIePSdb1jFk9Wm/7gma 9y8MlWZw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhDW7-00BJSR-LJ; Fri, 15 Sep 2023 18:26:11 +0000 Date: Fri, 15 Sep 2023 19:26:11 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Suren Baghdasaryan , Yang Shi , Michal Hocko , Vlastimil Babka , syzbot , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [mm?] kernel BUG in vma_replace_policy Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 023BE4000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6dng7um6pipqyrahatehmk7iq5atgztc X-HE-Tag: 1694802378-241684 X-HE-Meta: U2FsdGVkX1+U0L1Iu7GCCkCnkG7z+crm2quPKDedVpzvc6sA2sRVpXYc1F/RQAzNCIy22aLwggnTKeVJTw0a+jBziNKXg6lyKuNwcg6Dk6G/qzPx1k8R/uAawfWKCPslkcgMmDtc3Iw5BZL7guvLvvfX6DNIpr38c1DujvoG4owhQx28ETlfUIyojGhj6PUF7s4G5jyrwUXfWcGXK+WrYtwcEOUJTQerRtCHVCE6SWydBm4Pj/itPdICNp7muRbJRlu/c37Z+GOelC4WVHPr+PUXfZ4z7uWbRN+ppiuxcJXFvJ3gzFQKcW/lhr5HVI6MelsHYUgVeXQ2iaxC7gmbsauVJsgpjfJnFh+2No7byh6X1JQsB/HCzseTnYodX+FLLAyMp2VDcHbZfKezPGXXhxoGcJfeZSPLNcSX4LSbcOUrulU8c/FR5FgOepYQjEt3J9ZDGIeGn6UO2Fo5UXfsej3sRk9r3Ykk2yMjswo0plF2Lx89N98mjyFlP9Bl5Inj/uOqP/n526Y8LZTFPYyREwivyBrO2TsuGLtszfRZylqV7K0++7KxgCXH+a/vqKqFBOVkZkadQOE/2EPcuTWw+sIwPiaCJkGHqBPbOdPPAjkpB/uF57I1l60KIkK9YmpfIvFPr+DMGk56Pe5KdbwYLQzJ8WA7RJsmhe0FZuonvwpa3/ntbXCnC58q8tUB5SXwDUW6AglV3htfZyG3xFydvDGIJEBay3d1+PMaQ7z4DnG3pa/Ky/2t7CJYZ/WW/gxCLmZ1EODpqzYik8wknNekvmGr1u3Rk9i+XndFIH2f4LcOmXUwazA+8Zy/3mIbuehHwDPxd/ZfE8xw6bwrbthw63vd1Gr7+Ypox01flu7mAQzICQO9Aw9MaJhwvAfKBqgmQyISR7IamJclLnPTp6rk70UTW+JhvzTnHlh/IBfwENO3Nsq7XZzkPViGfninwC+Felv902iF4o1af/BnaMB MtiYd1EJ d5O6sBENVAq9YID+g8xGsRILZYi1eVG46nVUOa+jX8WwFT0n9BQ+RGCWy+DgOG53ziqLQva+jeUTlD9NOpTD4wuzhXqSEaIibiTk4AH7KNBkzs31BkmB6kMUMjiNvX3TOLePygXsfx38uxKIHU6UAvku1M1bMsdeVDK4SxpuGrTs/ovC+8dhVqHnAZlvzBylyGdE8P5Nvy89s8lmasfCf8Q0vwm3Nm1v0Fn2i4ThOmxoU/TGxZiZHaFD98OaMG9QAEIMfE5OK3DsZA3H0eBDOgWSVfppM4R2c6EVJqbYi3En3zKGyCsvRC39VkSbqCsa7T0HZ8h8K8ZXGJJc0Egg29iLsR3E8JuPUfPtCDTALVOhJeN/j8u5ayRmw6MQRyGdDOEzJ 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 Thu, Sep 14, 2023 at 09:26:15PM -0700, Hugh Dickins wrote: > On Thu, 14 Sep 2023, Suren Baghdasaryan wrote: > > Yes, I just finished running the reproducer on both upstream and > > linux-next builds listed in > > https://syzkaller.appspot.com/bug?extid=b591856e0f0139f83023 and the > > problem does not happen anymore. > > I'm fine with your suggestion too, just wanted to point out it would > > introduce change in the behavior. Let me know how you want to proceed. > > Well done, identifying the mysterious cause of this problem: > I'm glad to hear that you've now verified that hypothesis. > > You're right, it would be a regression to follow Matthew's suggestion. > > Traditionally, modulo bugs and inconsistencies, the queue_pages_range() > phase of do_mbind() has done the best it can, gathering all the pages it > can that need migration, even if some were missed; and proceeds to do the > mbind_range() phase if there was nothing "seriously" wrong (a gap causing > -EFAULT). Then at the end, if MPOL_MF_STRICT was set, and not all the > pages could be migrated (or MOVE was not specified and not all pages > were well placed), it returns -EIO rather than 0 to inform the caller > that not all could be done. > > There have been numerous tweaks, but I think most importantly > 5.3's d883544515aa ("mm: mempolicy: make the behavior consistent when > MPOL_MF_MOVE* and MPOL_MF_STRICT were specified") added those "return 1"s > which stop the pagewalk early. In my opinion, not an improvement - makes > it harder to get mbind() to do the best job it can (or is it justified as > what you're asking for if you say STRICT?). I suspect you agree that it's inconsistent to stop early. Userspace doesn't know at which point we found an unmovable page, so it can't behave rationally. Perhaps we should remove the 'early stop' and attempt to migrate every page in the range, whether it's before or after the first unmovable page?