Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp828813rdb; Sat, 7 Oct 2023 00:29:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5h84J9bBBdHc8wt6epVy5wrRuoZcDucZ32a3mWoah3bZ4cavXHZMeSFB9qr9vUAmwNhJ6 X-Received: by 2002:a05:6a00:1506:b0:690:cd6e:8d38 with SMTP id q6-20020a056a00150600b00690cd6e8d38mr12219010pfu.25.1696663795196; Sat, 07 Oct 2023 00:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696663795; cv=none; d=google.com; s=arc-20160816; b=ALhJM30n9YPyuPZxUAjOT385nfC/E17up6cx/tRY7For5m+1y2QjudKsqNDT2WRugh YugcgrEcMkbpxnwxZRNfdXPLGatdWVO5II/WxpNKALUUmoSdjTPLWlyOSX83UodL6kmk JrBnbLRFU5huv/9ZGMtJvhO3XkGJzlY9EVLPy0tcHJd8n3nMTv6TLQ6Y0zUvXXu4bMoc cAd7pmd8WCpxwaKMxqAOdLmxQVG0ZgyAJf1ZBu8zwb3c1YWrSyf4Fd/iTZ+Va6LdE+oM FJpaFhImu7nUVg6V+cfWQ4esXTF4DcIbaaDoFfERIp6jyxhwSCMW1eQi2Tbgo1aDa39n QCUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=yW6cLWnxr8WxRHJcT50sPQV85mo01atpIaprRDaD6T4=; fh=ZHbUCF9fmPmCN5C9oQfK7iLplnU6IRLBa2Wj+MZaJFU=; b=ZkMttWk4ylOvrt4us6ME2wPE2eUSPg4GatgRbxzHkIXq6Pdi/+D5CpNM95ls9PxWMD 5T0SO9YdZ5ZdZFhnTLTXCZ991xujKSf51Aw2BPYP0LTnzHAELWEcFrU9jerQ6hmvhx8J oGdmXHZijF7hQZZds89EsM+FnJi0WvdKvlfVmpCQPq/jcxMI8l6bXJL7bsIdmKmOXxh+ 8RXDqr6iTZVufEAdEr4wGEUYzVmdn/DEVaodwCWgE1r5B8rXLWPxO4+tJWdoSeqdCceD TngJqozeBSctkFWvyv3ky8+qnjxd4rdEKi/kvOisIJOAAnElZ6medRgkct44NZ9oR8so cDEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XkxLB8kc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id d16-20020a056a0024d000b0068e3f55075esi3217315pfv.134.2023.10.07.00.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 00:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XkxLB8kc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 270A2803E9F1; Sat, 7 Oct 2023 00:29:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343713AbjJGH3m (ORCPT + 99 others); Sat, 7 Oct 2023 03:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343632AbjJGH3k (ORCPT ); Sat, 7 Oct 2023 03:29:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A6FDF for ; Sat, 7 Oct 2023 00:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696663777; x=1728199777; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=KKsNX1B4ephXy3wePWdgK65UEebN0b8CYmREFVzaYus=; b=XkxLB8kcPupSoCwHMN1w4I/J3oD2UHlVluX/dZF/plqno785ojFrIrDA FLnddfmkpZAq4ddaGaoKz6Kf+DR8AHOX7n28KsQw7wDlwg76qblQrySgh ZS9b9I4p9kG/RJcE2g5idIyNWFeeCYqct5TfNBCgVEAW57lfqUna9a1SW vqsyWaVP9hkWKMY7juIifDBOi3J7zlpFAS2PGw4i4nHnr1F+sOVQ8QFAq ZvN77mH9SYJ8d43EmQOYVxovsgQshR/cA3DbQMDo2G24l71JWR21TPg8k reJVCcukKtnX0m2DW4merjswrr0zSjLIGwa5JdSce943VjkkPHk40wIR/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="382768536" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="382768536" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 00:29:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="868608902" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="868608902" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 00:29:32 -0700 From: "Huang, Ying" To: Hugh Dickins Cc: Andrew Morton , Andi Kleen , Christoph Lameter , Matthew Wilcox , Mike Kravetz , David Hildenbrand , Suren Baghdasaryan , Yang Shi , Sidhartha Kumar , Vishal Moola , Kefeng Wang , Greg Kroah-Hartman , Tejun Heo , Mel Gorman , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 03/12] mempolicy: fix migrate_pages(2) syscall return nr_failed References: <9a6b0b9-3bb-dbef-8adf-efab4397b8d@google.com> Date: Sat, 07 Oct 2023 15:27:23 +0800 In-Reply-To: <9a6b0b9-3bb-dbef-8adf-efab4397b8d@google.com> (Hugh Dickins's message of "Tue, 3 Oct 2023 02:17:43 -0700 (PDT)") Message-ID: <87o7halwo4.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Sat, 07 Oct 2023 00:29:53 -0700 (PDT) X-Spam-Level: ** Hugh Dickins writes: > "man 2 migrate_pages" says "On success migrate_pages() returns the number > of pages that could not be moved". Although 5.3 and 5.4 commits fixed > mbind(MPOL_MF_STRICT|MPOL_MF_MOVE*) to fail with EIO when not all pages > could be moved (because some could not be isolated for migration), > migrate_pages(2) was left still reporting only those pages failing at the > migration stage, forgetting those failing at the earlier isolation stage. > > Fix that by accumulating a long nr_failed count in struct queue_pages, > returned by queue_pages_range() when it's not returning an error, for > adding on to the nr_failed count from migrate_pages() in mm/migrate.c. > A count of pages? It's more a count of folios, but changing it to pages > would entail more work (also in mm/migrate.c): does not seem justified. > > queue_pages_range() itself should only return -EIO in the "strictly > unmovable" case (STRICT without any MOVEs): in that case it's best to > break out as soon as nr_failed gets set; but otherwise it should continue > to isolate pages for MOVing even when nr_failed - as the mbind(2) manpage > promises. > > There's a case when nr_failed should be incremented when it was missed: > queue_folios_pte_range() and queue_folios_hugetlb() count the transient > migration entries, like queue_folios_pmd() already did. And there's a > case when nr_failed should not be incremented when it would have been: > in meeting later PTEs of the same large folio, which can only be isolated > once: fixed by recording the current large folio in struct queue_pages. > > Clean up the affected functions, fixing or updating many comments. Bool > migrate_folio_add(), without -EIO: true if adding, or if skipping shared > (but its arguable folio_estimated_sharers() heuristic left unchanged). > Use MPOL_MF_WRLOCK flag to queue_pages_range(), instead of bool lock_vma. > Use explicit STRICT|MOVE* flags where queue_pages_test_walk() checks for > skipping, instead of hiding them behind MPOL_MF_VALID. > > Signed-off-by: Hugh Dickins > Reviewed-by: Matthew Wilcox (Oracle) Thanks! Feel free to add Reviewed-by: "Huang, Ying" -- Best Regards, Huang, Ying