From patchwork Mon Jul 17 11:36:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13315468 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 7F4EAC0015E for ; Mon, 17 Jul 2023 11:36:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C96EE8D0001; Mon, 17 Jul 2023 07:36:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C475D6B0074; Mon, 17 Jul 2023 07:36:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B35508D0001; Mon, 17 Jul 2023 07:36:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A2F136B0072 for ; Mon, 17 Jul 2023 07:36:46 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6C95E1204DF for ; Mon, 17 Jul 2023 11:36:46 +0000 (UTC) X-FDA: 81020901612.15.7CC9CE8 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf02.hostedemail.com (Postfix) with ESMTP id 2515380005 for ; Mon, 17 Jul 2023 11:36:42 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689593804; 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: references; bh=jXzjYqJH8Rz5Yx2vVdFqD0YEIdom4cS5bfIM6QMu+ME=; b=LoXdWVtbG186Gn2WLKaha2MyQIVezgE6yIWwPgff4IYxA6Z6MhjBPGVIDESKNq8Y1dSWLw w5/vMwoemIJFveziZ/XVHCbDFVFta3vvvERNmlNEkEU6B7pgpoOMPjA7r5lJYaLdZ5bOFH Fh1TPhQMZv226mwpI8/uiUggfCIHorg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689593804; a=rsa-sha256; cv=none; b=5t1I9JiqfoaT72lDUNNDYFzBuE3PpTpnejhno9E+G968pkE+8ZauoYNBJTqoqckTL4Ldqc thJ3wgxMNUIQ/f4ZZjudwZPUBjmEFg0KsAThat7pbyHEg5i9Ddze/uvTc3tPlBCQ17ijEe nL+qiNQMo5q4J+RTazf22kybKmkuBgw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R4Kjc0KmFzLnnh; Mon, 17 Jul 2023 19:34:12 +0800 (CST) Received: from huawei.com (10.174.151.185) 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.2507.27; Mon, 17 Jul 2023 19:36:36 +0800 From: Miaohe Lin To: , , , , CC: , , , , Subject: [PATCH] mm/memcg: minor cleanup for mc_handle_present_pte() Date: Mon, 17 Jul 2023 19:36:44 +0800 Message-ID: <20230717113644.3026478-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2515380005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: if9eghhxzc5gja6rwr9d764scgcinu7i X-HE-Tag: 1689593802-451195 X-HE-Meta: U2FsdGVkX18JupTaxC7IjkQ3rdUJbd6I98q5DZmqeUbfPMA4jOflToPvRBa+brtcrPdp+FUNiHLXkwENtnikHWExhyBIu7tsqOvlu6QGbwZifft5sh1YNSJkmg2Hh/j3uIweGTfHExDfzElYeO3nL7LOkqb2ORwGdwtWBDtf4CulJC1X25yggzxD3DWN0YV6srldLCpIDRKY5f0bdjCfr74LSpvEFGkLi5/Xww5DGjhHijDksjj6fJQiXrvEhY48uF4y/FKTXqvRSE9gKEGerDaGSdypxyU+f7DfcN2PUUrd0nUBGigfrpRNpZlW6FoXYkiFq6O+cFCgusBkqfqxjFTF08wTTN0OawGe046X5Xs5Vy+3q+JlxnEcPorh2dCVOf8Wu4EDbOeXQFCtUfR5cAFK7j6TG+cxlO60BNePPewkez+1LgRuBMqOu8APpxhG1wtPeXmhvgacqnvLN/esYtwP4m/O6gOxf8V8FqodzHvsOoc+Jglc5+QTkwNZL/22+DfUC9dSAozfUMYG7X8Oa5vmSt0yq32RxT3fG29or2XwVpPa1PBIGhsEmdTSbbWqzfNE6gERJsduVr2ZCUGGYH4JHm6wbQdK0IXACMT01sz3DJEhtaxa/JdBTYqqcyi0duyKWtyLq5kL9k9UO8TBDHsLTX3GblMAkIggg0g4GymBhiooYkehlOwAHZ2aULLGiN8fNF8mgTb9QVRqQHmV/xD05QDqEgjXBSoek0Kbwa8WNdSSaQ/vsRY2c2NqZrG/MsEwUFFUGwRQ0FECC9AAt26BxJmUX0QI81GhGKwQIv6O2oZaMlH+wnL65KIg4ZIi8MMyasmIOak5pQnsbG54Q8MJ6+exNDzZK99WHoJJuhuHP8dWDllaPzcBhexQtRNxr+NikWsMtNFXn6p9oEyoY89qIDqCbq7+PjX5+mtXWhrrBJC/vZWQ8D6b6vjeo1vEzwXClOim8gWcH10Mf1g uECB6xZ6 xP/zEMy4CkZfU7dJQegbC7eDsZdqp+ueL0Vo7aPCG9/5b6yceyg8ps3N1xh0j8pkFkhgfuZp4G8cgZaQzyIKf6oWeUPh95qtjKsb/B44wmrhXZwZMXmIvkZ2mUjC7Q7bgP4Zzu/vGlMamUNPlvcVwMgskB1Xttmy0WXAed0Bv3EFmoc0c0LRJlClvYkyGvbWEgv/e 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: When pagetable lock is held, the page will always be page_mapped(). So remove unneeded page_mapped() check. Also the page can't be freed from under us in this case. So use get_page() to get extra page reference to simplify the code. No functional change intended. Signed-off-by: Miaohe Lin --- mm/memcontrol.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 284396ea8a33..60b5ff3b4a52 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5649,7 +5649,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma, { struct page *page = vm_normal_page(vma, addr, ptent); - if (!page || !page_mapped(page)) + if (!page) return NULL; if (PageAnon(page)) { if (!(mc.flags & MOVE_ANON)) @@ -5658,8 +5658,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma, if (!(mc.flags & MOVE_FILE)) return NULL; } - if (!get_page_unless_zero(page)) - return NULL; + get_page(page); return page; }