Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1999399rwb; Sun, 14 Aug 2022 18:31:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+/DTF8j4jiDqv8OP+4Lz21sIV3+5mUXSST9PUhLDJ+wjxtCusalT24LfVzh4Bf43fafOa X-Received: by 2002:a05:6a00:2352:b0:52e:a03b:76f1 with SMTP id j18-20020a056a00235200b0052ea03b76f1mr14246008pfj.34.1660527074103; Sun, 14 Aug 2022 18:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660527074; cv=none; d=google.com; s=arc-20160816; b=P+O/ud5nZ9N15trwlgzmsfFvlw7OdpDqR6DWk5Pz2oWO8itzb7qLF6HBXybdmhUWjJ tg09F9KnVmg043HJzJ1B5Z8d8CL3PoLZWokbYmlASkWu1VzEi6H2lfbUaQTktRcKt4eY HVyEQw3MgEaRcO2UjR2jWSF9esF42lBZ4s/8BSuiZn6ZJ8tHpaq4V1G0IAaf+42L7hPy Bw+NLNWmAwDUQYz7G2i9aXjeDX/kaEzFxMXYKGGz5FfM6guM/L+EKqt5Yl4jzKnbhRLs iDVJed62TP1ESJ3LLEC2WbcPfIMSpKDl3uNNNdJc6igzF5HrWfV8PGG3VhtOAgk8re7J npaw== 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:date:subject:cc:to:from :dkim-signature; bh=TW5aLozSfEFNEaUPfuQ7159iYgjPVED4osgH8qKTcys=; b=IYe1KBtcKjccZaKTPc1lO6tD7d2zR58MxU5k5mvN2AME8CbUpT7tTIfXrxlhxhb1B8 vEg1tNEmmBWPf3ZJMj8n6Wy8yhFnJOMMsAjNbX57HOyhJ6nLMWhQilzdLMXFFOtfpPI2 kLEPkDztRIHC/PSdvUmL4XS9zVxli5xo/jFDG9dedfSWshbNq/KmMxsdOlGKnh3c+EhR zXuM8+j2tdDGWSj7ueb0nqHk1+kcZiLb0/yxBPO61nIT9aClznEd8gf42xBa3y/4fSV/ JaC6Mm81YIj/hpe3dJTBMuxmfKYzuKm0CRg8qm0K/j0HylmhWCFvOVxgv1AgIPbkBfyW oejw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TfgyAjTc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a17090a899000b001f2b468c2aesi7949279pjn.150.2022.08.14.18.31.02; Sun, 14 Aug 2022 18:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TfgyAjTc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231463AbiHOBDn (ORCPT + 99 others); Sun, 14 Aug 2022 21:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiHOBDk (ORCPT ); Sun, 14 Aug 2022 21:03:40 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAF4DFC2 for ; Sun, 14 Aug 2022 18:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660525419; x=1692061419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SnO+KuyY2Ig6pp+7jgz3mFNr913uLAxnryQVGv4z4qw=; b=TfgyAjTcLo34s2I8WfF5bBGn+TaA2C8c7VhMHpKpIe6ekij2VBVBVP1H p8Jq1lNeXQb4LPu3ODePz5njFjwTzAfOtS+MeSPvYB1G40DuOaOh29RGr bH6tYnWEQGH1btFSaYjdEvntyB7EWnI8l89g07/jbMOBQAM8cNXjelMps VL9Svp9oE4P9p80/yVleYN1fsezrvBn1WA5O0wLRIRu8mufxQmZq0gcZz kIH+BDKVN9D3DBKslknsgBOKLPjU2/2bBJXY4Q9Stxq5pS9ZxI7qOcLBv 89oSxIqCN11oAhE7jlCuMvU7fzAB+42jE+b8GZrsjb7bMfrWz5S0L6otN Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10439"; a="355872161" X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="355872161" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2022 18:03:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="695823581" Received: from sse-cse-haiyue-nuc.sh.intel.com ([10.239.241.114]) by FMSMGA003.fm.intel.com with ESMTP; 14 Aug 2022 18:03:36 -0700 From: Haiyue Wang To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, david@redhat.com, linmiaohe@huawei.com, ying.huang@intel.com, songmuchun@bytedance.com, naoya.horiguchi@linux.dev, alex.sierra@amd.com, Haiyue Wang Subject: [PATCH v3 1/2] mm: migration: fix the FOLL_GET failure on following huge page Date: Mon, 15 Aug 2022 09:03:48 +0800 Message-Id: <20220815010349.432313-2-haiyue.wang@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815010349.432313-1-haiyue.wang@intel.com> References: <20220812084921.409142-1-haiyue.wang@intel.com> <20220815010349.432313-1-haiyue.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Not all huge page APIs support FOLL_GET option, so the __NR_move_pages will fail to get the page node information for huge page. This is an temporary solution to mitigate the racing fix. After supporting follow huge page by FOLL_GET is done, this fix can be reverted safely. Fixes: 4cd614841c06 ("mm: migration: fix possible do_pages_stat_array racing with memory offline") Signed-off-by: Haiyue Wang --- mm/migrate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 6a1597c92261..581dfaad9257 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1848,6 +1848,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages, for (i = 0; i < nr_pages; i++) { unsigned long addr = (unsigned long)(*pages); + unsigned int foll_flags = FOLL_DUMP; struct vm_area_struct *vma; struct page *page; int err = -EFAULT; @@ -1856,8 +1857,12 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages, if (!vma) goto set_status; + /* Not all huge page follow APIs support 'FOLL_GET' */ + if (!is_vm_hugetlb_page(vma)) + foll_flags |= FOLL_GET; + /* FOLL_DUMP to ignore special (like zero) pages */ - page = follow_page(vma, addr, FOLL_GET | FOLL_DUMP); + page = follow_page(vma, addr, foll_flags); err = PTR_ERR(page); if (IS_ERR(page)) @@ -1865,7 +1870,8 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages, if (page && !is_zone_device_page(page)) { err = page_to_nid(page); - put_page(page); + if (foll_flags & FOLL_GET) + put_page(page); } else { err = -ENOENT; } -- 2.37.2