Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4657679rwj; Tue, 20 Dec 2022 13:16:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BXlsvXpDYV0d34dK3DtWKfqNrM+alVB8kQMYaajqDMrWrksAMCePK9wDUAdKCpEMis20l X-Received: by 2002:aa7:df88:0:b0:46d:c288:e798 with SMTP id b8-20020aa7df88000000b0046dc288e798mr42100812edy.21.1671571006630; Tue, 20 Dec 2022 13:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671571006; cv=none; d=google.com; s=arc-20160816; b=cix0DdEPqLzimnhrJE8FClHNaEoiyHhrpd9oACQosIAObhje+5WiC9fWUWG14zFy/q kNBq5BO2OZDpOym6TagNuD0kp++YXWUfGZmSNOqI6cKiDBSEB7QS2tTQpRB6MSBVHVjp z/4HdLh8ION4OMGA4+y+gK5oL3/zLfedwkf+PFDhKLGtnri19V4iqIhQUhzlI6WQwc9t TOq++9r75DRMJmMJ+7vuRg1TD7DbMHOk4uWN2qh5PFfJ986htI5PLcPQgcChUeiS8Wjp MUtvbt1/ZExEpugSNScuD7KfHaSyfcfjuHu7FdMUDiy8dp0dG93c+gwfzYZirI124j9D X0qA== 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:dkim-signature:date; bh=Y37zBw2z34AekRtu6QE+ZHXpaydFvXhSYB4OwYr6Iew=; b=n2vGH1/jQibJBLHeaCcfTIDXjFgL7UoccpPZrDoR3pTZsw9oRpQ+QJQKCJ8Ksl+AmQ eWsstwn83DSEk0kPar08sdTzshDpg+wYmMNLkmGRG8eyQngHwYljJilFqANdfuWCWVxL 5ZXRQmrx1DBGV2b/dWJ5q4U4/vCEL8WFwDqQP5awoqxmFCXiUypXHz6ElX+5TgRlzuWL H/qBXmnne+9Vtp01cAma7zUnk6Vz93l0CW3GBmsvF+NVFFeWsWO8hHWRUiIktIg07b3M OQeEMm9a5pUjBSZQ52WlLfyZB0TnOYijYqLf+93G2U2lEYTqsqet1Dj3oGit2XjHm1te XNKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=k2tEgNCe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020aa7d983000000b0046ce7fe346dsi10710193eds.231.2022.12.20.13.16.30; Tue, 20 Dec 2022 13:16:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=k2tEgNCe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234339AbiLTU7u (ORCPT + 68 others); Tue, 20 Dec 2022 15:59:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234201AbiLTU7t (ORCPT ); Tue, 20 Dec 2022 15:59:49 -0500 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABC565592 for ; Tue, 20 Dec 2022 12:59:46 -0800 (PST) Date: Tue, 20 Dec 2022 12:59:40 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1671569984; 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: in-reply-to:in-reply-to:references:references; bh=Y37zBw2z34AekRtu6QE+ZHXpaydFvXhSYB4OwYr6Iew=; b=k2tEgNCeJh1eRpPJ92swxPAVLxAUrukjoi5xvKpU7tyQKrSgio9+6kQaTDBhZn2wjzF03T laGIVhKyL9PhsRhc8uTgtEG+aRnANgJE0Rdz/aGTKAp3GeL8i+VdmfooHGoTAvO8nIPERh X7XL41kR1leDKMbChd4CqsUnhf5Rtvc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Muchun Song , Andrew Morton , Waiman Long , Sven Luther Subject: Re: [PATCH RFC] ipc/mqueue: introduce msg cache Message-ID: References: <20221220184813.1908318-1-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2022 at 11:53:25AM -0800, Shakeel Butt wrote: > +Vlastimil > > On Tue, Dec 20, 2022 at 10:48 AM Roman Gushchin > wrote: > > > > Sven Luther reported a regression in the posix message queues > > performance caused by switching to the per-object tracking of > > slab objects introduced by patch series ending with the > > commit 10befea91b61 ("mm: memcg/slab: use a single set of kmem_caches for all > > allocations"). > > > > To mitigate the regression cache allocated mqueue messages on a small > > percpu cache instead of releasing and re-allocating them every time. > > > > Seems fine with me but I am wondering what is stopping us to do this > caching in the slab layer for all accounted allocations? Does this > only make sense for specific scenarios/use-cases? It's far from trivial, unfortunately. Here we have an mqueue object to associate a percpu cache with and the hit rate is expected to be high, assuming the mqueue will be used to pass a lot of messages. With a generic slab cache we return to the necessity of managing the per-cgroup x per-slab-cache x per-cpu free list (or some other data structure), which is already far from trivial, based on the previous experience. It can easily lead to a significant memory waste, which will fully compensate all perf wins. So probably we need some heuristics to allocate caches only for really hot slab caches and use some sort of a hash map (keyed by cgroup and slab cache) to access freelists. What I miss to commit more time to this project (aside from not having it), is the lack of real workloads which will noticeably win from this work. Sven provided a good example and benchmark to reproduce the regression, so it was easy to justify the work. Thanks!