From patchwork Thu Feb 4 10:53:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12066959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7E36C433DB for ; Thu, 4 Feb 2021 10:56:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7540764F5E for ; Thu, 4 Feb 2021 10:56:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7540764F5E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9A6BC6B0005; Thu, 4 Feb 2021 05:56:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 957706B006C; Thu, 4 Feb 2021 05:56:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86C196B006E; Thu, 4 Feb 2021 05:56:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 72F006B0005 for ; Thu, 4 Feb 2021 05:56:21 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3E675824999B for ; Thu, 4 Feb 2021 10:56:21 +0000 (UTC) X-FDA: 77780281362.19.fork34_51001b6275db Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 1D88A1AD1B0 for ; Thu, 4 Feb 2021 10:56:21 +0000 (UTC) X-HE-Tag: fork34_51001b6275db X-Filterd-Recvd-Size: 4126 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 10:56:20 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id t25so1845531pga.2 for ; Thu, 04 Feb 2021 02:56:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bomnKjBCXlMUt7cumGwFSxIt2tLEfiNfG1uDxtiHzHo=; b=meRFeoFABKNahcTD5pEZi9cJb0xVYtEo0jR+vAzCdEludgjz8sf1Qlv2/xeRPDfibp /MMKS0gDIAcIwS+spfwSSxSYmiHHlYLXKz78sdAEln7aHWvn0QsCJNlPvKVOmygR7EfF nSWXTdN5o2V9xWtAhYeJgMlGZE86yc7er/RVSRnjuvKWa6RjgUQXsVKFyMLzh72oLILh ZefaeRzKTsudfYwco8W1CE1Vr2eIFb+VxUGIitkSeo2UM5YS+/bx7Xwr9TH4t1EkX+rc uS0RLOQkFJ07jRmOC12Y7X8c6oWiSWepD2xx1ceyRtqiYop3Hqiqt9lcpsOK7wc4pLM+ sZlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bomnKjBCXlMUt7cumGwFSxIt2tLEfiNfG1uDxtiHzHo=; b=EudyYzaptZJaRRx3GZYVfDnOtajRjoghsT/ERKq7EvbFY1KvwyPn/A3x2kJMwuPi1r j0W02eJUzekxNaAqYMmSK7SZJkmOr70YPCLOTa+Ro0lO+TC9GiaLkgzsUuY00+l4YrRO oD2fHteQJRRDVar3YR0KXy0JHpHLx+A3bEpaxr9jO2FafdI8ajsXBVauGuCdQPYbbKnk /rYgHDAwdLL6/jL0IsqTrJLkQ7DrFn4um0AtVtIaFZ4Dve9MteH6xqaDz3qvK2rRnPii 7NKskf7Ldj1+TAd24panXwPcR71FiriQoXc+eUwVTCrYa4gceu2UaPWfaknZMWTQeWrF DY+Q== X-Gm-Message-State: AOAM5336rYHHcV4MEacMYvCgKz1xbuygQSLujDEfbspSaTWiclYYNxNo GZYouaWdWKAUUXFKTzIXcMj1aw== X-Google-Smtp-Source: ABdhPJxUgUArlXg8y2yW1BuiqYJ2lzKT+G+NfzP6TzP4jp5cEnjoQAINnZWIf/miYy7OqREs06CHgA== X-Received: by 2002:a63:375d:: with SMTP id g29mr4490430pgn.226.1612436179150; Thu, 04 Feb 2021 02:56:19 -0800 (PST) Received: from localhost.localdomain ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id z15sm2043493pjz.41.2021.02.04.02.56.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Feb 2021 02:56:18 -0800 (PST) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm: memcontrol: replace the loop with a list_for_each_entry() Date: Thu, 4 Feb 2021 18:53:20 +0800 Message-Id: <20210204105320.46072-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 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: The rule of list walk has gone since: commit a9d5adeeb4b2 ("mm/memcontrol: allow to uncharge page without using page->lru field") So remove the strange comment and replace the loop with a list_for_each_entry(). Signed-off-by: Muchun Song --- mm/memcontrol.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6c7f1ea3955e..43341bd7ea1c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6891,24 +6891,11 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) static void uncharge_list(struct list_head *page_list) { struct uncharge_gather ug; - struct list_head *next; + struct page *page; uncharge_gather_clear(&ug); - - /* - * Note that the list can be a single page->lru; hence the - * do-while loop instead of a simple list_for_each_entry(). - */ - next = page_list->next; - do { - struct page *page; - - page = list_entry(next, struct page, lru); - next = page->lru.next; - + list_for_each_entry(page, page_list, lru) uncharge_page(page, &ug); - } while (next != page_list); - uncharge_batch(&ug); }