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 B6335CD37B0 for ; Sat, 16 Sep 2023 02:54:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21A146B0441; Fri, 15 Sep 2023 22:54:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C9FD6B0443; Fri, 15 Sep 2023 22:54:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 092886B0444; Fri, 15 Sep 2023 22:54:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ED8246B0441 for ; Fri, 15 Sep 2023 22:54:21 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C4A42120834 for ; Sat, 16 Sep 2023 02:54:21 +0000 (UTC) X-FDA: 81240941922.11.FFABF65 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf27.hostedemail.com (Postfix) with ESMTP id 11ED34001B for ; Sat, 16 Sep 2023 02:54:19 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WTvAYpr3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694832860; 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=pRgYEKeBnhc137LJPUJ1YX5jXl/+dvV/D/bsE7EFVFU=; b=rQUSRgPwf2DrjrNyxlhaSdSoHfivnI9VfXeSgjnQRtD4XR/RmWV51SOHmdcQ7NugaMYcSi KQpV2SWhoJq+yzlDM/uQj1rCBGonyoRNyqy5g6Dwm3e6LbU54cGQFEpqPCYiU1DRifL8Jr mabEDhNFuq72Dy7edMiwmWgWlWW24Po= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WTvAYpr3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694832860; a=rsa-sha256; cv=none; b=xAmS7EfxUA+rotpOD0vtl655x/KVR1JabADyjL3K+HmGr6B3xVdHZqbTKeShE1H1rAFcxW 5BAA5yPgJvOw7bjta4E6rbq02tiCr5kwQ8XoeHlWwJigOTFqFRp7aZonhgHhLfq3niedyP MuoUr41bQ3FH5tsQ7zLLksPEsMqCPOo= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-59c07cf02ebso16194567b3.1 for ; Fri, 15 Sep 2023 19:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694832859; x=1695437659; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=pRgYEKeBnhc137LJPUJ1YX5jXl/+dvV/D/bsE7EFVFU=; b=WTvAYpr3ir991ry4XC6dQvhlSAl8S7VyOT2sqfYrO/F2G5RNf6FLbndr0E4nIBL/gm R26o991jV05GLkNw1YHWeK3DEqnoAQZg6iWxUznt6PgVYebY33thGZLKdruuizP3G5PU SEf+YrL/D9vgl/58ycCMHIhdJeS6SI0ZlLgXN0hZnZOzNXvxhE/+GTRBt9tYg+yaKg7G /lLNpGY0XgotAuXFF1tIeSlYQSTlecoYJWAargjxAvLqAGKkUQ8L479Q0A0sufJASTHX RcoMWCaFHm2oBkByUoNXrdzLdZxjKociExXDDLfvAYlJndnbySUKtr1rtPs1tF6V8d17 dVjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694832859; x=1695437659; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pRgYEKeBnhc137LJPUJ1YX5jXl/+dvV/D/bsE7EFVFU=; b=UNAsKSVaGRiQ5qSunr8zEGb76re6NVJCIUobfoB3t9jNqi4pFj87dEOi49LxyoT2cM sTsz7WWMipFEdmas2FTOOVl59TiMyQij1D6tRB+5MnHB9XkCUbzzwmP8fnutIydWl/gI KQHFCNd2tVAGpHhyHVpUt03LqUwjhVMgIJkbBUT5YXwVSd6jaBkSj+w/uvDJP8T7zMWU nUHQdB43CKJ65Jcr5gteji/o/SU8Vxmq2vnUACGHUt3L0WLzo0VXDu5/0nwoOPVwQXvW umJvodXM4uHiHKZjEijhYujPAuCidgIghybaqMsIApXLOnkyYMPj3jcCWcUZ7W6TecOY VJPA== X-Gm-Message-State: AOJu0YzgXnra1jD4BNj8j7vnmUB1zvjhttRDsjqXMnFPnVFNWNzMWF0K xeZyZJaXTzFdBfMkhxAg1ojHCQ== X-Google-Smtp-Source: AGHT+IGyKMGHnMEM0WFtSTclUrFRubYqjyVdCHiMGPhbY5XPEn9cF7hIB744pXwvKTtzMGrN/Y+6mQ== X-Received: by 2002:a81:73d5:0:b0:59c:3f8:b0ab with SMTP id o204-20020a8173d5000000b0059c03f8b0abmr4202510ywc.41.1694832859109; Fri, 15 Sep 2023 19:54:19 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u127-20020a0dd285000000b0059bce30a498sm1196082ywd.139.2023.09.15.19.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:54:18 -0700 (PDT) Date: Fri, 15 Sep 2023 19:54:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Matthew Wilcox cc: Hugh Dickins , 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 In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 11ED34001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4z61tms1er5i8b7ic1qxyif4qp16jgwb X-HE-Tag: 1694832859-518716 X-HE-Meta: U2FsdGVkX18ObAmhF3h8WtXXpB3vrwYP81PDaPsb48n5gaZsK3miWye+3zhC4eMUP3KIOl5K6SqUxuyGprXsiUZyOq41fuGHPA+9EQ9NdnNnA0Jzh02CQomxOJvyB1IELuzJhG/K2YozPzYXjwkV7lQ5uT6dricBSW5maSIWldiXRG4deGmEGJSb9eOzFqPRHMH/XILXEpQWMgy2V61HxcvNy6RXTwqBian6UjBbdB2GUCHt1YQZz+QBZjKbmwuKUfXIq5GfhJevoFwqqct+TJtgyrEHq3rfPZn034nKrOoEBdKXK03/Ck7zbQKQQWNFnntLddKOrkLmsEST3Qonzkdrb0MhShuPsDgFjNE1Wg8cjilMvkrlhaEX+a/qNoXLYrZD8LqoQ7+Ji9mxd8C2bTwX7NzSKOfeTIZYlMGOHBLHk0X29wBlz1mMbZGtesHxodxCHgnEt9UbpK4AX5FR+y8CWzEl/bcckmYZY15Pt/IjuX84lsj7NFQ0K3BOqigRRR+2XTsDUIAr7SOy1BoN7gxNw83Ng1qAzaVspJo+wwkLif+YGiN675fm8n7WObzQCMSGqD1+mjLeLs6IXpG3Zu2uzKr04MczdqILaa6Ne2RDJiWQVoQtN3JLOIQqvwc7Ea6LVAI9qDtrMWcFS1WdGvEneCAH4zHhAAzFwXa8+9Bvu5JCOjsbdBICAsJFBnQDF+fLSDGGGLVUZC0gXTpjqthOEkHzh4Cze6WEM64CXcfwCWdKlvziqixE9NHiA40J29ajbkk6Xin96BOgiwOYJuvBMROfDs8snI9MEzDZkthfa5aAGbGt6yY/tF/0wYDTlNVqzOGspnhjrknebqrWlZOLD4RjHBWHeluXjZO2/2HVf+w5nWtdlMqI9DUpC42lsdMwqTj9fPqAGFwNsyaditJrT9jLdny82kfp07iZoO58c7FSYusDeewrkDtTMXaoH2gb6hNJ8gFyG6bwaB8 4W7V3+K/ RKfc+X7u5EkwbiLBOi3hyr/rJJtTXIebYIJwpae0SjS4JNsI+sE6olCR5QLZBqA45UrMLGR7eMToDuRwYXACsJmKThfdDTtO2G7jUD+lD1Bbgr+cp5D+HcItNpnxgqzZDByHoK5HAe1JMu4NWQZRqYFswLf5g6PH9hQowVCbbrhOKnRfxvV30T0hdfHR/5Za9EyfvMKeeU3VQsKFPktj05GFrR4ei2SO6Kk1jrW2QP2Bl4gTaFWzdebkpk397EjNTYf8aLI9uaJTo3fJlC3p+rf6y3kN38BGjGlxV+G9I4mRVrk+eETRac5IxjJBVWUUmPh4zDejiOct303aVDaS0M8KloPN5rKy0p2auOhVuf33tih9bQ+OOC+zVCxYrm0OW0/W4/QczSpYaJX94/aqsMTlF0ZfWFtKrnQGfw/fLrBUWj2/U5P1W5SU2umXMHOs74Nz7zPK0awCu0mZZigfLjcACww+9wIOE2P1cG0DfVRg+5L3ld6GzVSumpiN2h7BFRmLD/427LLDcQkCv5g2JFPZdNcvAME5q4y3grF3eaNWFFFoqo35D20Wp10zfWC92D/N1S9jdt+1igHwCHq8VkFlXbf5OE17r3h/RitFyQThCZAo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 15 Sep 2023, Matthew Wilcox wrote: > 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? Yes, that's what I was arguing for, and how it was done in olden days. Though (after Yang Shi's following comments, and looking back at my last attempted patch here) I may disagree with myself about the right behavior in the MPOL_MF_STRICT case. Hugh