Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5866895pxv; Wed, 28 Jul 2021 23:54:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW1s09a09DR4R/Pro31LrW8twYQ63lfgo3S6MQXSUNr97qLA2aeosOpAmVfJAa4uCNinva X-Received: by 2002:a05:6402:358c:: with SMTP id y12mr4240470edc.329.1627541646358; Wed, 28 Jul 2021 23:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627541646; cv=none; d=google.com; s=arc-20160816; b=eQj6jhSJQwtrbumEmrBiWCyDoAJq1135xyk69tPyFtQ6Na1BbcEjmlhORPWq7xZaxj WddTT7ybsVg18B0wm6iakOABcBJRgmIOR+T/h9WOvqVq6BNGkmYYjIwYDRxEkJfE39Kw ASixZGzI4KYya9r+aiUlokkNK+K4RjzASN839Stijfra1MO5dBU7QJiBPUvV6YWtKEfh MS97J65AinZJHd0JkySJiv1WlKBROMkPhgX/7r1OuNIQHc6RAWHE1GnW9JzabDO8ShD8 U+nWE/lVbG59n0LQYt8FHm7wHFOFAauKmPeHh1oWISyhpZ7I/cVqaEWwZYUgj8s6Tvhq hHXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=LX95wMuFmtvJvRbrQSf1vq546Z8po8lbIaSBIg9ApQI=; b=LZzlGAftXoTbyGdLuz4IiQBTsXU6mwpg+lOPIlbmVo7bgstphHn8qQQuVihkeICkFi PBaencUFfK9PghzUuCpOO9TLVYGh7Ev3oWR5z7eXIuVvmOjClB9By3tFTa1aMbRvaH1G +Cl7O9c1MFtGc5W9+HK/93uPVIpegxQl5UGn+yCeEVaHNQXrG5MpacluIb2l+7qHmlnY zP1Lpf9LNtBi3xoJkcFJBZl2i8cqaAcC3k5crxgI7uh3HEVvgy6TNbNHrxhQMwsF/dAU snMtAjJQSRqAzbU4zdFL+o0k4U04wA1FMKYiSTJFemLsnG5oHFDYHXCVxDr3d0gRufO6 oUMQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si1916879edq.379.2021.07.28.23.53.42; Wed, 28 Jul 2021 23:54:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234369AbhG2GwX (ORCPT + 99 others); Thu, 29 Jul 2021 02:52:23 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:13209 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234161AbhG2GwW (ORCPT ); Thu, 29 Jul 2021 02:52:22 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Gb1Jr6CZrz1CQDk; Thu, 29 Jul 2021 14:46:20 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 29 Jul 2021 14:52:09 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 29 Jul 2021 14:52:09 +0800 Subject: Re: [PATCH] slub: fix unreclaimable slab stat for bulk free To: Shakeel Butt , Christoph Lameter , Pekka Enberg , David Rientjes , Vlastimil Babka CC: Michal Hocko , Roman Gushchin , Wang Hai , Muchun Song , Andrew Morton , , References: <20210728155354.3440560-1-shakeelb@google.com> From: Kefeng Wang Message-ID: <8c14efe2-69dc-6eab-3cd5-c042576770e7@huawei.com> Date: Thu, 29 Jul 2021 14:52:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20210728155354.3440560-1-shakeelb@google.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/28 23:53, 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 > --- > 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); Could we add WARN_ON here, or we got nothing when CONFIG_DEBUG_VM is disabled. > + 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_);