Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp558326pxj; Thu, 20 May 2021 16:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkLbGtOWAwA8HTy8wU9EBuuMk6bAFIdIOI1Zjw0qMhCH/YmvNWj/qVBhbNdsYX7jPUxFq7 X-Received: by 2002:a17:906:f84:: with SMTP id q4mr7155626ejj.442.1621552299064; Thu, 20 May 2021 16:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621552299; cv=none; d=google.com; s=arc-20160816; b=ZWMDoKBveRA/urj6BCPVFPbeiV6pK+0/RPuviKWJR0q5aQgNspyalhu2dYWJiNfmXg DRoSQUHInos/a/DJSjFrmEwfd2mCfim/5jg0C1eKTXM+Kt5evx9tDh5D58CH6IZIxuaI 6tBShMq51/jqE1o6q2Ov24UGnK2aVscrE/RGF8HfCpfv4P899lWzOxZtr/mPNY8vFy63 x/5rcnzQ+OlNczoSBqakWW2I9wWGmVZIJxCtocwIT507qTs2/BHQaU68b0INiRVaAcnH jfpg/C/y+cz8X3CZpH9EfY/cnYTESn0mpUYOiDYNFg0DUCsLGVD2kI7aA/2RPXPZFMpK 0Nkw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Qulk5DLoSy+ozaztdE/91XH0VhEsMsS5lOTpU03M5A0=; b=gpWxAlWERN/HXRcz3vysqedHTjjHgGammy9F8hAlCUkxICS54QqfKI82ypCgNspjgv GIO6TEFaGoJkyLb3bqpc2nKVURN715qBTMoPE99UcjxSsRJyyAD5WZstn+xhyigL4piK sMlt4LeLsr6q2Gb8TYOfey4l5oi2jWeOgz2qHFx3Cc3ag1lCrEIUEFsXZxYsgc+0jfe7 gJFahnYM9fRFSW8SFLfk4LaMmjpJZzMahChcn41Nyg88Td5QhYdHu4waiPcMhsJLLePb nRA8XoNatvdmOGlGnodw9y3Eam9Zmj8sIfeZt2hkZE7fT3W/6KgO+wsZLO/tEAp3axIV ui4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1sOb6FbI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si3165395edv.171.2021.05.20.16.11.16; Thu, 20 May 2021 16:11:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1sOb6FbI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238830AbhETLX3 (ORCPT + 99 others); Thu, 20 May 2021 07:23:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239809AbhETLCd (ORCPT ); Thu, 20 May 2021 07:02:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AAB561925; Thu, 20 May 2021 10:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505053; bh=Vw5QKD1Sz/YNWUyJ1j/o0e85Lywf3RtbcVTZm+WeXFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1sOb6FbIh3UAnE2jMxYWXdD+igSpPe3iPOiuAtOTLagqux/5DsMOfFE1B08mnk6Zy /G6hxExsAtdbSBiD19aKQNAY+f0a1I2noTxGR0afJPmpS4NQxLAYlLl4wpB3bD/t/V QutielW117ihScMA3fKx5heR/oxeSqDL4J6Arp0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , "Kirill A. Shutemov" , Dan Carpenter , Ebru Akagunduz , Mike Kravetz , Rik van Riel , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 201/240] khugepaged: fix wrong result value for trace_mm_collapse_huge_page_isolate() Date: Thu, 20 May 2021 11:23:13 +0200 Message-Id: <20210520092115.402247186@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaohe Lin [ Upstream commit 74e579bf231a337ab3786d59e64bc94f45ca7b3f ] In writable and !referenced case, the result value should be SCAN_LACK_REFERENCED_PAGE for trace_mm_collapse_huge_page_isolate() instead of default 0 (SCAN_FAIL) here. Link: https://lkml.kernel.org/r/20210306032947.35921-5-linmiaohe@huawei.com Fixes: 7d2eba0557c1 ("mm: add tracepoint for scanning pages") Signed-off-by: Miaohe Lin Acked-by: Kirill A. Shutemov Cc: Dan Carpenter Cc: Ebru Akagunduz Cc: Mike Kravetz Cc: Rik van Riel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/khugepaged.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 753b0e2fef36..0f1bdbae45e2 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -596,17 +596,17 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, mmu_notifier_test_young(vma->vm_mm, address)) referenced++; } - if (likely(writable)) { - if (likely(referenced)) { - result = SCAN_SUCCEED; - trace_mm_collapse_huge_page_isolate(page, none_or_zero, - referenced, writable, result); - return 1; - } - } else { + + if (unlikely(!writable)) { result = SCAN_PAGE_RO; + } else if (unlikely(!referenced)) { + result = SCAN_LACK_REFERENCED_PAGE; + } else { + result = SCAN_SUCCEED; + trace_mm_collapse_huge_page_isolate(page, none_or_zero, + referenced, writable, result); + return 1; } - out: release_pte_pages(pte, _pte); trace_mm_collapse_huge_page_isolate(page, none_or_zero, -- 2.30.2