From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DBCAC433ED for ; Mon, 3 May 2021 14:20:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D8BB1613BA for ; Mon, 3 May 2021 14:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8BB1613BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EAFBC6B006C; Mon, 3 May 2021 10:20:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E86386B006E; Mon, 3 May 2021 10:20:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD9A46B0070; Mon, 3 May 2021 10:20:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id ABEE46B006C for ; Mon, 3 May 2021 10:20:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5196F180ACF86 for ; Mon, 3 May 2021 14:20:23 +0000 (UTC) X-FDA: 78100129926.01.4688226 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 7960FA0002DA for ; Mon, 3 May 2021 14:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620051622; 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=Cba/OYMboyUL2DtaynOpgQ1aSITP9mKlivymjF+E18U=; b=NQZhnH9ZWALyz6kWO1nfj1MtC5TSODE6v8hau9ZIU8dnIVYhXVzZXYL9avto0kk6dTFnA7 /q1iGrO7MChNnHd/x24fbVQEsoWnlLyrUN/iC+q4g4ztMjsBRIOuaZ387gwV2Xg46+ACNN VIZg4EnmvzdOQW745NOqfpa1ZLH8mhM= 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-484-B9Pq4FLGPouZhFfHSJhsuQ-1; Mon, 03 May 2021 10:20:20 -0400 X-MC-Unique: B9Pq4FLGPouZhFfHSJhsuQ-1 Received: by mail-qk1-f197.google.com with SMTP id c4-20020a3781040000b02902e46e29acf5so5201880qkd.22 for ; Mon, 03 May 2021 07:20:20 -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=Cba/OYMboyUL2DtaynOpgQ1aSITP9mKlivymjF+E18U=; b=pW6hYZvVr4NpJB45ixiJoajGzGGNwtFHi0d8YjLRfmiHqeXdieUnKaiwrBxoiyoABE 8usArXl36XL7PM6D/tzAUyv5173VkJc3GK9a/4jiR0Oqu9Pi99XM3cIY+Xg5y6Ph1wv/ yOenCgkZ3m2sxwHvGgQEaI3vnWLjQA51LW/gRRHselFeucXtTgFbHP8UrBIn37qqa7rs W2t8/hah7Tk3ultYrw83+dQ3DzYx0h8qiXwQy29gOikDCJ1OOrIuBBQbmplALCUn8JhF LeZ9peOyDUkuCihWzeqpIQVBNtAOmjeJs8nixQCqzxBYMJvZS07mdIXIBDB9K8HnHYR5 9ROQ== X-Gm-Message-State: AOAM530GmkImXCzYMIAhgqiXUl6MFPFInS5Qfi53YIvC3ni/IKoj/Zmv +U0/3SSoWo2liJNT5JfN2QKxFzYCXXG5xlvj26T7xqzIvQtcyggQoBsFXTLymC+Fr8KotFireaM RLkSBMJ7UufR0gFB27PC9tOaQW6pL1EwyAT0KJ/3nN72LiD8wKAI4E7K1WQg= X-Received: by 2002:a05:622a:15c6:: with SMTP id d6mr16903576qty.172.1620051619935; Mon, 03 May 2021 07:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRarG4Zi4peWlqgXlLk5yiZcgOvrdkvZtDmZ1mwnE32A43M0N16VhKdpPc8PH6nbBYcwoXwQ== X-Received: by 2002:a05:622a:15c6:: with SMTP id d6mr16903539qty.172.1620051619684; Mon, 03 May 2021 07:20:19 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id v10sm8614891qtf.39.2021.05.03.07.20.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 May 2021 07:20:19 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [PATCH 2/2] mm: memcg/slab: Don't create unfreeable slab To: Vlastimil Babka , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Shakeel Butt Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org References: <20210502180755.445-1-longman@redhat.com> <20210502180755.445-2-longman@redhat.com> <699e5ac8-9044-d664-f73f-778fe72fd09b@suse.cz> Message-ID: <4c90cf79-9c61-8964-a6fd-2da087893339@redhat.com> Date: Mon, 3 May 2021 10:20:17 -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: <699e5ac8-9044-d664-f73f-778fe72fd09b@suse.cz> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7960FA0002DA Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NQZhnH9Z; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf15.hostedemail.com: domain of llong@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=llong@redhat.com X-Stat-Signature: 17oq7e4cok7gfpj4f491sjzhkbgxpzij Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620051617-613045 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 5/3/21 8:22 AM, Vlastimil Babka wrote: > On 5/2/21 8:07 PM, Waiman Long wrote: >> The obj_cgroup array (memcg_data) embedded in the page structure is >> allocated at the first instance an accounted memory allocation happens. >> With the right size object, it is possible that the allocated obj_cgroup >> array comes from the same slab that requires memory accounting. If this >> happens, the slab will never become empty again as there is at least one >> object left (the obj_cgroup array) in the slab. >> >> With instructmentation code added to detect this situation, I got 76 >> hits on the kmalloc-192 slab when booting up a test kernel on a VM. >> So this can really happen. >> >> To avoid the creation of these unfreeable slabs, a check is added to >> memcg_alloc_page_obj_cgroups() to detect that and double the size >> of the array in case it happens to make sure that it comes from a >> different kmemcache. >> >> This change, however, does not completely eliminate the presence >> of unfreeable slabs which can still happen if a circular obj_cgroup >> array dependency is formed. > Hm this looks like only a half fix then. > I'm afraid the proper fix is for kmemcg to create own set of caches for the > arrays. It would also solve the recursive kfree() issue. Right, this is a possible solution. However, the objcg pointers array should need that much memory. Creating its own set of kmemcaches may seem like an overkill. Cheers, Longman