Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2332058pxb; Fri, 5 Feb 2021 15:23:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzs6X3nWNjbTgnDkIrFtdtegr27iGMUqlB7V6pQXkVq382eS+TP7Qszu3oibyuUfT+JdA0C X-Received: by 2002:a17:906:bc99:: with SMTP id lv25mr6119243ejb.15.1612567420541; Fri, 05 Feb 2021 15:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612567420; cv=none; d=google.com; s=arc-20160816; b=m7E+2s8LpD0/ucPFmAJlvG1nMmZ8i8oZ9v7QYe4QNTMyNCOVJtYVC54xDfcLS/6kpK 0b8+HiUPqSEDnjy7l50TLnkYzS8Jhyn3+fR7YQzic+RmM5fPC3ZLa+sY5xALeV0x7c2U jCMV7CnNSHJq/jgQr+gan7Cs0mSjhs/qTocblse3Zl0TYmWpvxuze9Yvlj/vFIXNpnZr lrQxFiM0Iuc6gK1X+pdWAUj9FxITrE163szusmHLDY0SMvPjWxLOHTnDe/MC/OPxDqSL GeGmVKqgAkkA8Xmncj4mYPQjCORnEesN2Cyx6PSy0hHpAPUKD0P8wGtMuVqt00lNih9e 6T4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=u6nLt32hHSRYEP44w6Q8jO52HR65E6F1MxMn+PffeCo=; b=MOVxrICeyEOcRTMUrMB3fb8nBRed3ioLOKVbVeKVBJpHKX8U0A/Si65koIOhJlfYrY 5H/h574Nw/DIcar3nwUEDzYmr1RRFLXMCkrnSemJgfCb6Y9PcFTz9hpVPhhAFcr0NQ6T g01/yYf7OhyBQFq+E86rB64I+IFd/0StCLKg5vvrjZrrooxLTvV/nq0QRBf4+JVK/5aq 9zN+7pU8sAsBeweVRiMR0HBrD3SwjKRuS5IJqhhnZViPthAP3TPPR4pSu71FXZxTZrNZ OFs5kSSo9zp9+zXvyi0b+Bh/NAW3y8iErUec7Nt0yYVd/Pr1p+/PumjSJh2tu/rwcFRP 9sVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eoMxcZO9; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si5928010edq.451.2021.02.05.15.23.16; Fri, 05 Feb 2021 15:23:40 -0800 (PST) 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=@suse.com header.s=susede1 header.b=eoMxcZO9; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbhBEXVl (ORCPT + 99 others); Fri, 5 Feb 2021 18:21:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:48732 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbhBEOZr (ORCPT ); Fri, 5 Feb 2021 09:25:47 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1612538880; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u6nLt32hHSRYEP44w6Q8jO52HR65E6F1MxMn+PffeCo=; b=eoMxcZO9AYC0lNv6Jl0zdS7Nnkz6VqMQWDpWPY1xlgnXmYy4t0pxybOM8SrwuOlrWKhsGW mGT+lqDRFr5ltdHWe2tkSYEMqhoSMUxGiAfYj2LFel3EN6KchlZISW+tyKV/+g7pR4ZPAI +kYu7WQjtB1eS0Vft4tcfEeYs8r9FL8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC35AB048; Fri, 5 Feb 2021 15:27:59 +0000 (UTC) Date: Fri, 5 Feb 2021 16:27:56 +0100 From: Michal Hocko To: Muchun Song Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: memcontrol: replace the loop with a list_for_each_entry() Message-ID: References: <20210204163055.56080-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210204163055.56080-1-songmuchun@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 05-02-21 00:30:55, Muchun Song wrote: > 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(). > > There is only one caller of the uncharge_list(). So just fold it into > mem_cgroup_uncharge_list() and remove it. > > Signed-off-by: Muchun Song Acked-by: Michal Hocko Thanks! > --- > v2: > - Fold uncharge_list() to mem_cgroup_uncharge_list(). > > mm/memcontrol.c | 35 ++++++++--------------------------- > 1 file changed, 8 insertions(+), 27 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index ed5cc78a8dbf..8c035846c7a4 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6862,31 +6862,6 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) > css_put(&ug->memcg->css); > } > > -static void uncharge_list(struct list_head *page_list) > -{ > - struct uncharge_gather ug; > - struct list_head *next; > - > - 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; > - > - uncharge_page(page, &ug); > - } while (next != page_list); > - > - if (ug.memcg) > - uncharge_batch(&ug); > -} > - > /** > * mem_cgroup_uncharge - uncharge a page > * @page: page to uncharge > @@ -6918,11 +6893,17 @@ void mem_cgroup_uncharge(struct page *page) > */ > void mem_cgroup_uncharge_list(struct list_head *page_list) > { > + struct uncharge_gather ug; > + struct page *page; > + > if (mem_cgroup_disabled()) > return; > > - if (!list_empty(page_list)) > - uncharge_list(page_list); > + uncharge_gather_clear(&ug); > + list_for_each_entry(page, page_list, lru) > + uncharge_page(page, &ug); > + if (ug.memcg) > + uncharge_batch(&ug); > } > > /** > -- > 2.11.0 -- Michal Hocko SUSE Labs