Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp900824pxy; Wed, 5 May 2021 17:26:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyszrlnH1dlq6MhieXUHFA3cDcLIAh/tG7O5of65tDJmHI56KEeJzbh8JJiQghCUK/lzqJv X-Received: by 2002:a17:906:3ec9:: with SMTP id d9mr1364040ejj.479.1620260801886; Wed, 05 May 2021 17:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620260801; cv=none; d=google.com; s=arc-20160816; b=tTvbygxFUBZsVhyYOZxcFaOWMnpaFY+xGGipBL8XbQklOEZesrzP+QrW49TKgQO3we oj7LsAnCcmNwl6gu07j0zcJKpiqiNyFItvLQlVC01j3RrLVFIJXum2P0ilI/d7ln/YhH 3kAYieRI15nTt8WOBt61m2l4UX+usiasn7gszPi0a4Vcv23W0+/grAMW0TcCaf/BQ/u3 PoGpuaHWCQGvUhayWKPxCQwNDUzEVn6PI9+l0Ze6vCm2OrD3pJa3HlTlPdU8lXvV12m0 0L7IvgcdxswBMQuopIDGWdQj3N/cdtGLGglF6pKEsUGGJWg7i0cFHdriAi2hfU4qZ9+U X7SQ== 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:references:cc :to:subject:from:dkim-signature; bh=Y2UtSfp8BrCUffF0CdlLACo8aqMI+/YAkO0AYQU2b30=; b=NkLnK2ZWWnsMxBqrCzgTt16ls1cOFKCv/Wk0je2NsWpl3e1H3RsLLhOq1YWGSzS7/W YHDMDiHqTKMohO5Htjhz03k7SldQuvbWBqXJbycmwIMmc8mMhdJtLpqRyn1Umja5kYYG tq3MKCew5r/1z32NXomtz86kXMzg9YyqszgHhc/2L1csBkJjuHPu57EQtGXIqzqKB+Rv 3Bto6lFl5EWuR9O724Brq23KZcgDhTfX/nJFnSngjGPwsD+Yd/XkSPBau6XS02s9hhio NI7WITHUEEs+DSWOTrac7IIpMscR2aKzr6bkzIMf7yTcBQ8MvS0mevmsee8NoypnbRVv qY2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NA4FDRR7; 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 v13si769740ejb.671.2021.05.05.17.26.18; Wed, 05 May 2021 17:26:41 -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=NA4FDRR7; 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 S229488AbhEEXH3 (ORCPT + 99 others); Wed, 5 May 2021 19:07:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22526 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbhEEXH0 (ORCPT ); Wed, 5 May 2021 19:07:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620255988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y2UtSfp8BrCUffF0CdlLACo8aqMI+/YAkO0AYQU2b30=; b=NA4FDRR7YR9+lvxBSwDmvobyBDqmrOSoy6dhUCKj4Qh/H5bskuWuNoekxIHut3zN29+mqK 4sKvARzHc75hFmpFZwZ6T77jt7o29cMNEMNUTPs3rmTy5odpXRkJrtpiTNv/pFwu1br5Ed Wd0iGvk/WEb5DDsC+DyVopEBd7WMTSI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-5c8d6gCoOwWN7JvuKY01aw-1; Wed, 05 May 2021 19:06:27 -0400 X-MC-Unique: 5c8d6gCoOwWN7JvuKY01aw-1 Received: by mail-qk1-f197.google.com with SMTP id s143-20020a3745950000b029028274263008so2235442qka.9 for ; Wed, 05 May 2021 16:06:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Y2UtSfp8BrCUffF0CdlLACo8aqMI+/YAkO0AYQU2b30=; b=Vo94sj8oL5dqLzfzUtZIohTDcKdlBRKHYOan8SAniguS3It5RsXQfSwtCDgAqat40z CmYtBm1VQxtEzBDsD2ODBwV4Maq/b22tHoBwMX+aCH6NAkLXOYFhg+zUYi7/G88fyD41 3hoqMdVo8+cF0ac2BDnOt+jsStj12YlZCRaWfUEmQe6ZbU6qGcE+9T9dTDxgjQ9mEoLx y1jFH/uWgLZkU2qa+AylnHO0dnaXHCIY+HNq4gfibm8qwz6VV8WGd98StOPOzCP/Tadg BwW6MIf3loX4nCxtLP2ipUlyRT2qcNGdPAodNXu2j9Cck652Fj9V9kPdQCGiYkJoS72m IYuA== X-Gm-Message-State: AOAM530mFje++PXbrR6WmepNicUULQrJdIcNO1ICjABKouWPSuSo5QiJ f4bYDiIlhPvDirjEhk1CF9i8pTwPJYgDrwa+kx59xyFbXG6bOieqWWE9fC4/Kvz5qiCiDihXTSl RS/U9cqFwGyZylbbMAuykd7pz X-Received: by 2002:a05:6214:f6e:: with SMTP id iy14mr1253373qvb.53.1620255986850; Wed, 05 May 2021 16:06:26 -0700 (PDT) X-Received: by 2002:a05:6214:f6e:: with SMTP id iy14mr1253349qvb.53.1620255986621; Wed, 05 May 2021 16:06:26 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id j196sm726721qke.25.2021.05.05.16.06.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 May 2021 16:06:26 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [PATCH v3 2/2] mm: memcg/slab: Create a new set of kmalloc-cg- caches To: Roman Gushchin , Vlastimil Babka Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Shakeel Butt , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org References: <20210505154613.17214-1-longman@redhat.com> <20210505154613.17214-3-longman@redhat.com> <235f45b4-2d99-f32d-ac2b-18b59fea5a25@suse.cz> Message-ID: <95ab4bdf-f373-f71d-cdf5-05ad6edbb772@redhat.com> Date: Wed, 5 May 2021 19:06:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/5/21 6:19 PM, Roman Gushchin wrote: > On Wed, May 05, 2021 at 11:29:54PM +0200, Vlastimil Babka wrote: >> On 5/5/21 8:32 PM, Roman Gushchin wrote: >>> On Wed, May 05, 2021 at 08:02:06PM +0200, Vlastimil Babka wrote: >>>> On 5/5/21 7:30 PM, Roman Gushchin wrote: >>>>> On Wed, May 05, 2021 at 11:46:13AM -0400, Waiman Long wrote: >>>>>> With this change, all the objcg pointer array objects will come from >>>>>> KMALLOC_NORMAL caches which won't have their objcg pointer arrays. So >>>>>> both the recursive kfree() problem and non-freeable slab problem are >>>>>> gone. Since both the KMALLOC_NORMAL and KMALLOC_CGROUP caches no longer >>>>>> have mixed accounted and unaccounted objects, this will slightly reduce >>>>>> the number of objcg pointer arrays that need to be allocated and save >>>>>> a bit of memory. >>>>> Unfortunately the positive effect of this change will be likely >>>>> reversed by a lower utilization due to a larger number of caches. >>>>> >>>>> Btw, I wonder if we also need a change in the slab caches merging procedure? >>>>> KMALLOC_NORMAL caches should not be merged with caches which can potentially >>>>> include accounted objects. >>>> Good point. But looks like kmalloc* caches are extempt from all merging in >>>> create_boot_cache() via >>>> >>>> s->refcount = -1; /* Exempt from merging for now */ >>> Wait, s->refcount is adjusted to 1 in create_kmalloc_cache() after calling >>> into create_boot_cache? >> Hmm I missed that >> >> Now I wonder why all kmalloc caches on my system have 0 aliases :) >> cat /sys/kernel/slab/kmalloc-*/aliases > Yeah, I noticed it too, it's a good question. And I remember a case from > the past when it wasn't true (kmalloc-32 was shared with something else). > The criteria for cache merging require close to exact match in all attributes with a size difference of no more than sizeof(void *). So it is not easy to find a close match. Cheers, Longman