Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1910414rdh; Tue, 26 Sep 2023 07:10:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhE1nt4yCJxgKMfTWmAdmhEXLmYY7RgCJamalwia2m5/9HsJZwYQ8bsqlbp9X4pZzI6TpX X-Received: by 2002:a05:6a00:2289:b0:690:41a1:9b66 with SMTP id f9-20020a056a00228900b0069041a19b66mr8661958pfe.14.1695737441259; Tue, 26 Sep 2023 07:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695737441; cv=none; d=google.com; s=arc-20160816; b=AfEdyZtTcNa268U03WQgVfjHTXW3EjR1+7gKIMfv1Gbo8tNwuCItVcLQjsHAkxJpo6 dUD40Y1414PgMFwJRN9AwdTnT6OxqHFlSchLlQRtK6l5zmQQQPBo7f8sYqaIY7MNUcYI ZVbQZKP1STpb3+ZSzE0ujboR09D7/fCv4mEud/4OFWms5IVtjxwqp1ed7JbngMqsQotF fq3cPIDTA2o7gZYRCQmGBvq5AXW+/xG8iaUXS6EMYdb51jlLgzamRqArE7b/oUW7xiYZ RCGmErtK5OS1ZH96F4BGo5/YoyixIsBITO7qHD//WxRzmn29ljGJpIypV1jtHfSaGisy +mVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=2ADckJ8hfwrEXitITVWEpOvTRYU/IALxGGUU6vBaWgA=; fh=GyxTz6dusLpdCg4kdRb3DUsqLeY2wtlY1WJfveWbq6Q=; b=GSmOishvj89IZlCke9XzYQD87897ELS2jkonIxfWu+hkx+g1iF5skvuwwRrAGYlavU 8adhGimseB5oBGgwvevUUrYZkkbrA/uG+PEw5OqIoUzLX9UQKBUxxUn8emFEmCAGGl5C k5bQHRwdWGJpM63Y85JUPuILi5HnEhnqpZreeVzdQ3U+5VJGiC2ktkmngoDM3Ytsst6a ycXtmswoSdPE+5aSaE9wkfOuvRPR2IZ60alWU/Ex0/IN5HnsA4FnABNicuWmkKdljS7s bS1vb+O7q0NMwZ2AeVupt8VWr6o24Q85rG0GAr8T+uKe3e4gaFIApvY0OgZZz2pXGqIG urWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Et6bCcEb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j13-20020a63cf0d000000b0057821ea0674si1934437pgg.812.2023.09.26.07.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 07:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Et6bCcEb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 430B9808D686; Mon, 25 Sep 2023 08:50:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232946AbjIYPuJ (ORCPT + 99 others); Mon, 25 Sep 2023 11:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbjIYPt5 (ORCPT ); Mon, 25 Sep 2023 11:49:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C997199B; Mon, 25 Sep 2023 08:48:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70841C433C8; Mon, 25 Sep 2023 15:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1695656921; bh=ydw6MbSohqavIDDQv26z7jnbFjP4NN+5JbvGYYNEn+Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Et6bCcEb6RTZ/kaR7i4cgQdrb85R3iQhBnO3yW+Ufr5ECgAVL4Cyt46Staj9nUkZU qfH8UwchovmBRYj00gpCCXcY9KFw2nCL6LN8ffmXsoWLc1y5qoPo3O+zkcI41n8d4I fuyGb7stM4MqvlNf2YeoX/VIhBryhPvwRf2oU2Uk= Date: Mon, 25 Sep 2023 08:48:40 -0700 From: Andrew Morton To: Yang Shi Cc: hughd@google.com, surenb@google.com, willy@infradead.org, mhocko@suse.com, vbabka@suse.cz, osalvador@suse.de, aquini@redhat.com, kirill@shutemov.name, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified Message-Id: <20230925084840.af05fefd19a101c71308a8cf@linux-foundation.org> In-Reply-To: <20230920223242.3425775-1-yang@os.amperecomputing.com> References: <20230920223242.3425775-1-yang@os.amperecomputing.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:50:24 -0700 (PDT) On Wed, 20 Sep 2023 15:32:42 -0700 Yang Shi wrote: > When calling mbind() with MPOL_MF_{MOVE|MOVEALL} | MPOL_MF_STRICT, > kernel should attempt to migrate all existing pages, and return -EIO if > there is misplaced or unmovable page. Then commit 6f4576e3687b > ("mempolicy: apply page table walker on queue_pages_range()") messed up > the return value and didn't break VMA scan early ianymore when MPOL_MF_STRICT > alone. The return value problem was fixed by commit a7f40cfe3b7a > ("mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified"), > but it broke the VMA walk early if unmovable page is met, it may cause some > pages are not migrated as expected. So I'm thinking that a7f40cfe3b7a is the suitable Fixes: target? > The code should conceptually do: > > if (MPOL_MF_MOVE|MOVEALL) > scan all vmas > try to migrate the existing pages > return success > else if (MPOL_MF_MOVE* | MPOL_MF_STRICT) > scan all vmas > try to migrate the existing pages > return -EIO if unmovable or migration failed > else /* MPOL_MF_STRICT alone */ > break early if meets unmovable and don't call mbind_range() at all > else /* none of those flags */ > check the ranges in test_walk, EFAULT without mbind_range() if discontig. > > Fixed the behavior. >