Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2298747pxb; Tue, 12 Oct 2021 03:44:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1cyGOT5IWE7OpEleL572MKHk0t124ThkQ9NZYw93lAmYsrgMInDJE06jeTXv6fCRuXwzW X-Received: by 2002:a17:90b:a18:: with SMTP id gg24mr4999313pjb.18.1634035463716; Tue, 12 Oct 2021 03:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634035463; cv=none; d=google.com; s=arc-20160816; b=AW+n8h8O/ApfBehBoD1Io2B3iXHGBRRZoYooE3ofu647llObDG0DgZ5qcIMFIA8svl hY76tFxlcX7gplMecWz0xgeoPGMP8L2n3ilbrJez+izltOuVCNrI61E0R6ocoyAXz8Xx V2vPg38XSePLYHCBmQP2MTxsa4G5rhSpRxdWvSnTzS5u+Mc8wZePpwse2G6MRlz6sz1o BOZCtfXbFF1FV5B1f2pb0cMztO9bjPI+U6Eea9q0ND1Z1Sg2au6VAXc5m9Yu2qgJEvsF P5yS1ZntHpHvm+oPgKovbV9shZ3STzft78lPtjlpR8cnzaEhhbIN77/ul7/feKBMZkcN PwUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=bEbXgNx8UNhTNiQSVrQ+7EoBtCdD7MvBGkcwxGWc4cs=; b=By0+nNfgnakuA3mTQMY0PnV7TUIjbNKMtj+owonLuoQws1T6Sg+2YFLFY7qUq2s5I4 ZAU/6szcJ8Tx+k2jVFh9GoN8N2u8R880HA0E+9iuEcLZZTHSeWcD+kPE/Hmf6dwGyDKz d5jQMhToJz1hn4eegHSIZB/ej8IsippX83oYrIKhHs6yMx+5AC38gRr+/dYO/SprURFA y6ujoBMB0lO+guZ6+9NBWM8bQd97/yeuc0jd+A4DMvaaI4FZ850vL1vyWr4TVdm19i+8 FbUJ5+ueUBkR+T6Mja3/HCPTZNzp7gKXqyqRKA/aq84YdbavyLPaZdEoQV02QwEIoJa4 vifg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=SmT2sdTN; 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=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si14161484pgb.526.2021.10.12.03.44.11; Tue, 12 Oct 2021 03:44:23 -0700 (PDT) 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=@virtuozzo.com header.s=relay header.b=SmT2sdTN; 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=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236032AbhJLKpI (ORCPT + 99 others); Tue, 12 Oct 2021 06:45:08 -0400 Received: from relay.sw.ru ([185.231.240.75]:44362 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235900AbhJLKpH (ORCPT ); Tue, 12 Oct 2021 06:45:07 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); >> >> >