Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4321567rwb; Tue, 16 Aug 2022 19:55:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6JSFRLyVW/kQBadmCbJrsRMkyMex+x+0Wb1IRrmShMJnkwTXvQhH02eFKunucK3HF+8A8d X-Received: by 2002:a17:902:e746:b0:16e:f7cf:671f with SMTP id p6-20020a170902e74600b0016ef7cf671fmr24235533plf.168.1660704948579; Tue, 16 Aug 2022 19:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660704948; cv=none; d=google.com; s=arc-20160816; b=FM22l0OXF/sxcDCpLSwdrTsdjJt7cZGn7MNBhn98jRC8cAHZlgLvGd1TQH8bkkjqNL Q3P4bybQ9Y8FnoZq5DQIt5Q/2mt94jn9+9SpTAlk+LHLe5rcFXSxhWnLJbjLxb06AsdJ Da6G3xDod3fF5gArBo7XvbGxFsRYkwwGoUQdUUENLM8mWWKR6TyvaOY0Sct7ls9Z4nIA uWunGYQ/gdN1il3bqzR+jmbCdsqoCYrf/xu16cR57I2ZyTnAG9HO1G/aDf6au3qZu5EG nzx2vfArCMO+yeXB6c0tzi6nIZ6F+rA64re+FkL5js7oAGn93ha0aW29xKA65KymimT8 BobA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=nI1jX0bEuucbu/umkPBjQQDwJ32podKXYgeXf3DjYsY=; b=A5mCOkSbvIZpx6GhpStJu2FJrS/HJIhYQKEGcUlU6NlU25rpXZDSqkgSiG3gqfDA70 9jqG6pMDA8Pp+K5BqeQCtE+UVU1CmtJVLjY7oAtQMu/0ZHQ7JFH8YZ7Ji+alBox8GSYe W1jbvQwXuQd3sMFHp1JHnCF7iCeuxXQTm9MvVgix5TFi7SxPUKnCvcxek5Lpmp6gyZbF lTgpCrs/a4bP1Xr6C93Eid0Q78kkHnafkOKrH+sFuYQkF5HwZcWBfqQLd+A09Bz2VWeY tLWBGDinONW3eBN3U9MiUNMZo01ChLnvMNxQjUBtBQn5ukdW3yxsy8BDqo/3AyN/15W8 Ec0g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iw19-20020a170903045300b0016a24d76abasi238503plb.298.2022.08.16.19.55.37; Tue, 16 Aug 2022 19:55:48 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238158AbiHQCeR (ORCPT + 99 others); Tue, 16 Aug 2022 22:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238100AbiHQCeQ (ORCPT ); Tue, 16 Aug 2022 22:34:16 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1981550054 for ; Tue, 16 Aug 2022 19:34:15 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M6sRs3dvMzXdNr; Wed, 17 Aug 2022 10:30:01 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 10:34:12 +0800 Subject: Re: [PATCH v6 2/2] mm: fix the handling Non-LRU pages returned by follow_page To: Haiyue Wang , , CC: , , , , , , , Felix Kuehling References: <20220812084921.409142-1-haiyue.wang@intel.com> <20220816022102.582865-1-haiyue.wang@intel.com> <20220816022102.582865-3-haiyue.wang@intel.com> From: Miaohe Lin Message-ID: Date: Wed, 17 Aug 2022 10:34:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220816022102.582865-3-haiyue.wang@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,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 On 2022/8/16 10:21, Haiyue Wang wrote: > The handling Non-LRU pages returned by follow_page() jumps directly, it > doesn't call put_page() to handle the reference count, since 'FOLL_GET' > flag for follow_page() has get_page() called. Fix the zone device page > check by handling the page reference count correctly before returning. > > And as David reviewed, "device pages are never PageKsm pages". Drop this > zone device page check for break_ksm(). > > Fixes: 3218f8712d6b ("mm: handling Non-LRU pages returned by vm_normal_pages") > Signed-off-by: Haiyue Wang > Reviewed-by: "Huang, Ying" > Reviewed-by: Felix Kuehling Thanks for your fixing. LGTM with one nit below. But I have no strong opinion on it. So with or without fixing below nit: Reviewed-by: Miaohe Lin > --- > mm/huge_memory.c | 4 ++-- > mm/ksm.c | 12 +++++++++--- > mm/migrate.c | 19 ++++++++++++------- > 3 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 8a7c1b344abe..b2ba17c3dcd7 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2963,10 +2963,10 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, > /* FOLL_DUMP to ignore special (like zero) pages */ > page = follow_page(vma, addr, FOLL_GET | FOLL_DUMP); > > - if (IS_ERR_OR_NULL(page) || is_zone_device_page(page)) > + if (IS_ERR_OR_NULL(page)) > continue; > > - if (!is_transparent_hugepage(page)) > + if (is_zone_device_page(page) || !is_transparent_hugepage(page)) !is_transparent_hugepage should already do the work here? IIRC, zone_device_page can't be a transhuge page anyway. And only transparent_hugepage is cared here. Thanks, Miaohe Lin