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 70AFCC25B0E for ; Wed, 17 Aug 2022 02:34:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFCBF8D0002; Tue, 16 Aug 2022 22:34:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAC4A8D0001; Tue, 16 Aug 2022 22:34:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B741F8D0002; Tue, 16 Aug 2022 22:34:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A5EC58D0001 for ; Tue, 16 Aug 2022 22:34:17 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7D6191C653E for ; Wed, 17 Aug 2022 02:34:17 +0000 (UTC) X-FDA: 79807515354.20.A1ACC35 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf08.hostedemail.com (Postfix) with ESMTP id 8264E1601DE for ; Wed, 17 Aug 2022 02:34:16 +0000 (UTC) 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 ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660703656; a=rsa-sha256; cv=none; b=02h7eRBxaDqy4oAcC7wqa9mQNPcZsWs93AHpzdfKzjOeFRM8+/yNV7G/jvEkK+JTh3S4C1 QI3JsRTGVrmml8bJ4H2vR+ij7t+nWEgQkxrAujO18z+nnnVvBs/g3uJzIZMAjBIi3M9Djn XJV1bWyOyvw968MlTrBLmaHh8Hqk3y8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660703656; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nI1jX0bEuucbu/umkPBjQQDwJ32podKXYgeXf3DjYsY=; b=FLFVj/9SsPpnKmLsfyVO+U+ipY6L8qt9/8nTEql5oC79Qh1BpjIWlNjwGomClaYuau4yh+ jyOFIP33kq8S7vaxLLpfcKDGTxv7XVXZH11aipyYVXloyp+em5b4EXAeBCp5i0TwEYquGs huAXWXxp+tyvxMOlhF+KPPnd2YpOj8I= Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: gwtrb1d1k6t3c5p1nouykxz7ed7uqma7 X-Rspamd-Queue-Id: 8264E1601DE X-HE-Tag: 1660703656-708916 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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