Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5399544pxv; Wed, 28 Jul 2021 09:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuGvL+JGJe3s43JVUkdOzYhG0jmSgf8lxHSfjGj8gScqLJRUrFaJ73Dh5rJN7CmBZ1EZ39 X-Received: by 2002:a17:906:c30f:: with SMTP id s15mr368540ejz.233.1627490930265; Wed, 28 Jul 2021 09:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627490930; cv=none; d=google.com; s=arc-20160816; b=jq+Xk3XAnNmhupIbl7W8htoNbuMDTwxDgH/u/s+wKaCIiHgUHnF66gjfNmShIQTnOX w/UCUK4xrZIF/hk1E4aDK3vnoMumjgZHiskpRhSV8/zt/qqljVw7Bk1R16PgPQhZNA3n N/t9MjhDuGRppGWsIOZZ/3JjZr+sKPfwRpYdIb/uZnCdxh3Qwo0gxeOlKbrq/saaOaCq Z/dMlrzTrElCN8kytgHRHYfdct1kurHmnPVqpq8kSdCZ7OjlpE9HUGutIsYJ2zbkl46R rUqQ0TIPJZ9sqAevF9nRJayhwDPv9ErNfnuydMaD66ixszKUkV3YwW36zar77jT72h0J 2eRA== 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=I4kQI0znLqLVVTW/73drb4OCrBjSeGIiwx6TpMRNhvw=; b=cR1E91eQJzHH0pchhCMUaY1DSqK0XSGPMEELmyG33YQyfFltx47jp6TKNBt4lp9b5Q VC6ojVNXIyo0s5hSSSbClhtahp4pQ1qkMjI+1sO3v5ySr5DyfBUT2V0STVNS28qEuh1B bHmsbaEwjIOzb7rtyVTlxVoiH7SMtybztdoVmO79z8HLKl54NA8q4I/9KSIWaq/vutgI 8K4NMb0Hy4GzHyvhHQjTWz7848v3Wnv2GQ2oQAcfFkzYg4S0IYePBctz86eyvbYDXERp fHDk0zzbPtIQvJm9DGen2dwIQRtQYOkL7Mvh+YmwVAl8+GMUmMG2BkPyQqscwa1wyMhi DVOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OtOWzic9; 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 g7si156402edy.6.2021.07.28.09.48.27; Wed, 28 Jul 2021 09:48:50 -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=@suse.com header.s=susede1 header.b=OtOWzic9; 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 S229663AbhG1Qpw (ORCPT + 99 others); Wed, 28 Jul 2021 12:45:52 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:58592 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbhG1Qpv (ORCPT ); Wed, 28 Jul 2021 12:45:51 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E0AC122332; Wed, 28 Jul 2021 16:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627490748; 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=I4kQI0znLqLVVTW/73drb4OCrBjSeGIiwx6TpMRNhvw=; b=OtOWzic9yUr6KdYRiYwZEIS8FBl3sUIrCOO41dU9gfruHKh9uRpCpzqGjATC3WGmGga4JD 0WJfgpdLkxHFEH60v8a6GGLaQOLlxRN4jVqtudoEcuXQnYFPT8zzR7DYHf0UYUOgY/OSId 3LJJrerHykDjRS0u4gKAWLQoK3wXAvU= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 79AB9A3B83; Wed, 28 Jul 2021 16:45:48 +0000 (UTC) Date: Wed, 28 Jul 2021 18:45:48 +0200 From: Michal Hocko To: Shakeel Butt Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Vlastimil Babka , Roman Gushchin , Wang Hai , Muchun Song , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] slub: fix unreclaimable slab stat for bulk free Message-ID: References: <20210728155354.3440560-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210728155354.3440560-1-shakeelb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 28-07-21 08:53:54, Shakeel Butt wrote: > SLUB uses page allocator for higher order allocations and update > unreclaimable slab stat for such allocations. At the moment, the bulk > free for SLUB does not share code with normal free code path for these > type of allocations and have missed the stat update. So, fix the stat > update by common code. The user visible impact of the bug is the > potential of inconsistent unreclaimable slab stat visible through > meminfo and vmstat. > > Fixes: 6a486c0ad4dc ("mm, sl[ou]b: improve memory accounting") > Signed-off-by: Shakeel Butt LGTM Acked-by: Michal Hocko > --- > mm/slub.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 6dad2b6fda6f..03770291aa6b 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3238,6 +3238,16 @@ struct detached_freelist { > struct kmem_cache *s; > }; > > +static inline void free_nonslab_page(struct page *page) > +{ > + unsigned int order = compound_order(page); > + > + VM_BUG_ON_PAGE(!PageCompound(page), page); > + kfree_hook(page_address(page)); > + mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, -(PAGE_SIZE << order)); > + __free_pages(page, order); > +} > + > /* > * This function progressively scans the array with free objects (with > * a limited look ahead) and extract objects belonging to the same > @@ -3274,9 +3284,7 @@ int build_detached_freelist(struct kmem_cache *s, size_t size, > if (!s) { > /* Handle kalloc'ed objects */ > if (unlikely(!PageSlab(page))) { > - BUG_ON(!PageCompound(page)); > - kfree_hook(object); > - __free_pages(page, compound_order(page)); > + free_nonslab_page(page); > p[size] = NULL; /* mark object processed */ > return size; > } > @@ -4252,13 +4260,7 @@ void kfree(const void *x) > > page = virt_to_head_page(x); > if (unlikely(!PageSlab(page))) { > - unsigned int order = compound_order(page); > - > - BUG_ON(!PageCompound(page)); > - kfree_hook(object); > - mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, > - -(PAGE_SIZE << order)); > - __free_pages(page, order); > + free_nonslab_page(page); > return; > } > slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_); > -- > 2.32.0.432.gabb21c7263-goog -- Michal Hocko SUSE Labs