From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9FC9C433EF for ; Tue, 12 Oct 2021 10:43:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 65C6D610CE for ; Tue, 12 Oct 2021 10:43:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 65C6D610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BA3926B006C; Tue, 12 Oct 2021 06:43:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B050C6B0071; Tue, 12 Oct 2021 06:43:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A5B0900002; Tue, 12 Oct 2021 06:43:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 861CC6B006C for ; Tue, 12 Oct 2021 06:43:08 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1F9CB8249980 for ; Tue, 12 Oct 2021 10:43:08 +0000 (UTC) X-FDA: 78687448056.31.3EAE66D Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf25.hostedemail.com (Postfix) with ESMTP id A38A5B000185 for ; Tue, 12 Oct 2021 10:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:From: Subject; bh=bEbXgNx8UNhTNiQSVrQ+7EoBtCdD7MvBGkcwxGWc4cs=; b=SmT2sdTNW0HEqxE0m moILfvR4WUkRN/qJdfdiDnBRMRXGquRZAofXgF5d54Zzkt1ln9tBN8XPALEk1iDBhHy8erFkLJ9Bo WnQyYEjYw1xSV/QWTN12zef+4kbJJVBsuatmIdz3aKFLQvIc7iGUuzKemcaf9gjg/k06zn9PtE2KM =; Received: from [172.29.1.17] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1maFFO-005nHz-Qb; Tue, 12 Oct 2021 13:43:02 +0300 Subject: Re: [PATCH memcg] mm/page_alloc.c: avoid statistic update with 0 To: Vlastimil Babka , Michal Hocko Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org, Mel Gorman , Uladzislau Rezki References: <29155011-f884-b0e5-218e-911039568acb@suse.cz> From: Vasily Averin Message-ID: Date: Tue, 12 Oct 2021 13:42:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <29155011-f884-b0e5-218e-911039568acb@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A38A5B000185 X-Stat-Signature: ypg65ohkfjjnsmofgm1xzh6qf4863tjf Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=relay header.b=SmT2sdTN; dmarc=pass (policy=quarantine) header.from=virtuozzo.com; spf=pass (imf25.hostedemail.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com X-HE-Tag: 1634035387-177735 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: On 08.10.2021 14:47, Vlastimil Babka wrote: > On 10/8/21 11:24, Vasily Averin wrote: >> __alloc_pages_bulk can call __count_zid_vm_events and zone_statistics >> with nr_account = 0. > > But that's not a bug, right? Just an effective no-op that's not commonly > happening, so is it worth the check? Why not? Yes, it's not a bug, it just makes the kernel a bit more efficient in a very unlikely case. However, it looks strange and makes uninformed code reviewers like me worry about possible problems inside the affected functions. No one else calls these functions from 0. >> Fixes: 3e23060b2d0b ("mm/page_alloc: batch the accounting updates in the bulk allocator") >> Signed-off-by: Vasily Averin >> --- >> mm/page_alloc.c | 7 ++++--- >> 1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 602819a232e5..e67113452ee8 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -5364,9 +5364,10 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, >> } >> >> local_unlock_irqrestore(&pagesets.lock, flags); >> - >> - __count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account); >> - zone_statistics(ac.preferred_zoneref->zone, zone, nr_account); >> + if (nr_account) { >> + __count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account); >> + zone_statistics(ac.preferred_zoneref->zone, zone, nr_account); >> + } >> if (objcg) >> memcg_bulk_post_charge_hook(objcg, nr_pre_charge - nr_account); >> >> >