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: 121227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1056721vqt; Mon, 17 Jul 2023 04:49:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGu5ETUJsS2+eWa1hUVpg/F6I/0lvycgPFB4yAWVvMy4HMvE4/0xW9ouCodJaRPj0pN6XTC X-Received: by 2002:aa7:c74d:0:b0:51d:f37b:1b4e with SMTP id c13-20020aa7c74d000000b0051df37b1b4emr10139209eds.19.1689594549868; Mon, 17 Jul 2023 04:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689594549; cv=none; d=google.com; s=arc-20160816; b=vfIj93Bm3mfinBQEWrq/hopV8Vx6z6ATnfBADqzwwVFnC4qJ4QTjq5bEZsbDmc2U6/ cG7IMXKLFAoFPFGOjY2A921rzhT3yfAAtI4GIPnpXBZuBSidmLS2iyyN4tV9qIDFl0o4 idrLhvkFm1Gl/tmItxjIZvh2UiCoyerwpRTY2CodF4MgfGJqVi0XK1JhzpZDU1a0F8iS UWK1ufgUE6QtwZfhxkVJ3c6CQXYbrMEy9n1Y7YpsVuLpD0Lw230KHZ4zQsRtwtcM+7X/ eljssZPh3UIY4zFpizZFbQQFhTbtc4/dWNE4U8WV4nW/6araNcQxV91OtpmMo0VjOqEg nG9g== 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 :message-id:date:subject:cc:to:from; bh=jXzjYqJH8Rz5Yx2vVdFqD0YEIdom4cS5bfIM6QMu+ME=; fh=qzFN4U0kifqIfd7P07Gk/0coMp1+a18+XFLbwN1xCUo=; b=SIvrFhCui0vGmQA99iC8WMvZs7m2TyU842k8DsMPg9UzfSu1SOrBBziYGK1+zPJsOP eu5dmZ/IDbugau1UtNIOFdU7c98wP4yeymPH5Vq4Xme+h5X0QS6zqZb08nnCzQJfdZnx PeyeIXjk6FwEDzB0iLef4yME5Nhls7o/FGVa0shQ+haRKW/n6fAJ76NFylw0TiYHWLVu UErslwYkSXDAG0cj2Jrt+besFH+7jbAPOSHneEOfvEWVAmXGTaS9yiaayKo32PqmAokL rnBEaTB0vw1H+zMm0yWkZV0lyNOr7oUSRBHcxLS6iUMzCgOelqmG39l1nWYH4ji8YUQJ KBiw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056402050800b00516b291217fsi14586429edv.0.2023.07.17.04.48.45; Mon, 17 Jul 2023 04:49:09 -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 S229927AbjGQLgo (ORCPT + 99 others); Mon, 17 Jul 2023 07:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjGQLgm (ORCPT ); Mon, 17 Jul 2023 07:36:42 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC9EE4F; Mon, 17 Jul 2023 04:36:39 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771668294818761518 X-GMAIL-MSGID: 1771668294818761518 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; }