Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp853484pxy; Wed, 5 May 2021 15:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxQKJkFym0u5RmwOk1d7LUqHyczmjjbc3N+R4tHGpbi8RVseo9vO9XZ4bX1Yf9A6Qew9j5 X-Received: by 2002:a50:dac4:: with SMTP id s4mr1429278edj.353.1620255366717; Wed, 05 May 2021 15:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620255366; cv=none; d=google.com; s=arc-20160816; b=vnpnXxDxyIYGWu+V2u8NlIGATf8thzkjtMLczNVYQFU+o5rZ2Fzs5Ba0TKmC3g570U MpBD/ZNgO23GJVXl4D3TfXQb/vvFAfNa5dOzmRcE/lNVgl+zDij99J3vN/ig1Auyc1Nv fWmqmMe3Ntj1L4ZRifDLzoSXO/27KbGajmFfFb8ASAuS5MuKtsSuwXoatrBLY3hjJnCM aa3M4Bn7SgPhelgH2YJN0TLWmSbFSlREXBav3b/r6LU8jBuIUChkxgWWeyKMtc5Jh/ja bbbfbvwrjvrpUqa6r359M2EG1MGlmCpAYO+o7oNdI26HIsPhwmI6gDIEItyfyFraa/hb ivGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=GObYidJPOxqa39RCGKtF8EH7OG9xQ65JoyiaTRpSe4I=; b=m1E9h8i0db+IS87Cer/BhMAzFhM0o8W51ZHSBE7/lnjRTQhdT1axG6iEGKpIYwllsu 2ZMM66A8CY1nfMlvNBsWO60pN6SgQdkWhWyUw25PKRzW5UqfhXnFGbAAumRVREUj4dmA wOOiUDm6PZN42DnlLgJ+W/j3jbSs1Az8oqZ1FI/u01lEMe8ZXin7WwRZJh7nTSBhUyuW m4NvtXLKgP/bp+LGcK6BTUnGCKHvZD4DTpf8bxiaNV1sSGvtVQLsTvV40FzsqyJQZpob oUOiVJg6ySMhFiQn+1TlT/9VXl0lkV9FlRTKjZP51ACeKNyk2hWP869/8Ga5nx0kmxd3 KQOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JSw5lM5n; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si697692edi.75.2021.05.05.15.55.43; Wed, 05 May 2021 15:56: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JSw5lM5n; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbhEEUHo (ORCPT + 99 others); Wed, 5 May 2021 16:07:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49724 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233800AbhEEUHn (ORCPT ); Wed, 5 May 2021 16:07:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620245206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=GObYidJPOxqa39RCGKtF8EH7OG9xQ65JoyiaTRpSe4I=; b=JSw5lM5nsX7TGEy38DjwnmKE2Sy9T5GQ2645ws9DxRt99bA6RfQvgLRoWsgNhPVZ2GorJ0 Pg3B1byi/4GZB8X0Jm7fXsA2Fug7yP1eUf+OChJdFIwA9xglCphK9heZV+DQm/AIH3Nvlt 1IASKGlnkuUSKcvORF6z9+G2h91sdTQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-AMamAWPhPeW0_g-6xgUE0A-1; Wed, 05 May 2021 16:06:42 -0400 X-MC-Unique: AMamAWPhPeW0_g-6xgUE0A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5899E10066E5; Wed, 5 May 2021 20:06:40 +0000 (UTC) Received: from llong.com (ovpn-117-4.rdu2.redhat.com [10.10.117.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D03A410016FD; Wed, 5 May 2021 20:06:38 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Shakeel Butt Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Waiman Long Subject: [PATCH v4 3/3] mm: memcg/slab: Disable cache merging for KMALLOC_NORMAL caches Date: Wed, 5 May 2021 16:06:10 -0400 Message-Id: <20210505200610.13943-4-longman@redhat.com> In-Reply-To: <20210505200610.13943-1-longman@redhat.com> References: <20210505200610.13943-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The KMALLOC_NORMAL (kmalloc-) caches are for unaccounted objects only when CONFIG_MEMCG_KMEM is enabled. To make sure that this condition remains true, we will have to prevent KMALOC_NORMAL caches to merge with other kmem caches. This is now done by setting its refcount to -1 right after its creation. Suggested-by: Roman Gushchin Signed-off-by: Waiman Long --- mm/slab_common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/slab_common.c b/mm/slab_common.c index bbaf41a7c77e..a0ff8e1d8b67 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -841,6 +841,13 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) kmalloc_info[idx].name[type], kmalloc_info[idx].size, flags, 0, kmalloc_info[idx].size); + + /* + * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for + * KMALLOC_NORMAL caches. + */ + if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_NORMAL)) + kmalloc_caches[type][idx]->refcount = -1; } /* -- 2.18.1