Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp684656rdb; Wed, 17 Jan 2024 14:20:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9dsGk+RjyVrSXIiLReO8E/N4y6F6SNNN6+wD7Gkb5sVR5KG78P0kRbQ/aIMclkmQkpJdB X-Received: by 2002:a05:6870:1607:b0:203:b171:c380 with SMTP id b7-20020a056870160700b00203b171c380mr12361589oae.98.1705530052606; Wed, 17 Jan 2024 14:20:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705530052; cv=pass; d=google.com; s=arc-20160816; b=JWs2A4TvSUO2wSO+hyWh8fANaqFIH8RDFlbLDXmhJp3Y3uY5pXVvNTJfi0L2Q27blJ c5wEwiscPAkDI7UCEj9ceUHqqlIR7H8YrLBETVQlxM7MVwXI1AAUv7CYHDmLgyW+d/JU RtZAsYv3ZEopUffrhxcA4XseWX0T2Uyw2glbcvHNnwNxYMSBRt38Deo6SoAGPzo97H4c xz2zlJkiD+254IKFz8PhBs8EBriZh4ihBISVZQmFqnJ7OEarTFs8xH8HfydN0r58BvwS aGN0MiQQT3CLEIJPqbUkPjmIOZPZO9M7tf9owX+BhJJFzc/5qgeem2gcz1uQ9dAiLqdU x7YA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature:date; bh=oEcZHshrstC6C+wvUe816o9OqrS9R+Ox74x4Ua6+cNg=; fh=2HfSL4FSUu3hr7Ea9Ac/YkJBdoBt4gz8x8iV1cDeQk4=; b=Mqbk/6dDzwuMnsl4cDzY0KtQQki7ZI05N/dUCQrZ3YEIOMogffvThKer5gqiedoJal xsJ+nQ2ZVBgSmMjRV7KsrfOYxaD6qNDoIguxr48E5du1Cq1xMtzIVjBhkH7pTNrmNdQ0 Zpp5yL+ncJEqzsao8sb96NrmqFMFN6TX7O58xexEJA3Wnv4DLSkPdpTbfrvzdMj9Gbaq TEn3LgXwrXEFkZRYTDE+6UOp0n77W2dR/0/0X2zfRFITBdpzlEnHHU/gzZDtE00Ced4Y hXcDjiBx8vWCDCJ/XXKhKF8sM/FQuLZcBHtLXm2svBrBADtom2yInaQ0dCG7GztXgI+W bQ/Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oo9nK5OL; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29483-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29483-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m3-20020a633f03000000b0058afac51c12si309021pga.545.2024.01.17.14.20.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 14:20:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29483-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oo9nK5OL; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-29483-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29483-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8064628AC59 for ; Wed, 17 Jan 2024 22:20:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 821B328DBE; Wed, 17 Jan 2024 22:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="oo9nK5OL" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A50B128DB5 for ; Wed, 17 Jan 2024 22:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705530030; cv=none; b=sjMWorPstzLh0QLnjinezycGb7ynHHqzEkaVSOgkXqIei27nc5FQj7U4sqUkqHYv3RV33Q8+qdbvDrBg+3+LKVQzhQuclMkNkq4JCjLw3KtpNvAcf9jMo3/ndvr6kIZrUXHrbBMHkTyqzhXSWins8hbAolMqNZUBVxsR3VwUgFc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705530030; c=relaxed/simple; bh=FePaCUEty5gnqt0K9AD8pYf32kGcc5Fn+FiwW9+63Wc=; h=Date:DKIM-Signature:X-Report-Abuse:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To:X-Migadu-Flow; b=cVwg7XXmlpN6ScvuE3LbDrBfM1wc+F7Zw62khxw/cb2cZYjDmpfOu0TcpkeyXrv9HMw+vD+jJs50Fu184qw9ecnKS5SCGYGttTBQBqz9rV9va3SINyQJAcdX9D5Aq5dGKN9fmMfvuz+UlYpe6EwmUuHGPL3bySZreLzW4j+V/yo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=oo9nK5OL; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Wed, 17 Jan 2024 14:20:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705530026; 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=oEcZHshrstC6C+wvUe816o9OqrS9R+Ox74x4Ua6+cNg=; b=oo9nK5OLo2HbxZhIYJMCnLJpYtsivfboaj7C7gJ0VoDQxxdFw+ieXQh3sl0taplJs8h6VR QHtAdhqNaftf5uCuLcn+Gug1pTa/9k1srBFS3O8bcAo1Y2G6At7h0Cmc+rTWn5qcGvGUQg h1JE6ZW/8v0YWbpn8rfHURYglSWqHUo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Linus Torvalds , Josh Poimboeuf , Vlastimil Babka , Jeff Layton , Chuck Lever , Johannes Weiner , Michal Hocko , linux-kernel@vger.kernel.org, Jens Axboe , Tejun Heo , Vasily Averin , Michal Koutny , Waiman Long , Muchun Song , Jiri Kosina , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH RFC 1/4] fs/locks: Fix file lock cache accounting, again Message-ID: References: <6667b799702e1815bd4e4f7744eddbc0bd042bb7.camel@kernel.org> <20240117193915.urwueineol7p4hg7@treble> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Wed, Jan 17, 2024 at 01:02:19PM -0800, Shakeel Butt wrote: > On Wed, Jan 17, 2024 at 12:21 PM Linus Torvalds > wrote: > > > > On Wed, 17 Jan 2024 at 11:39, Josh Poimboeuf wrote: > > > > > > That's a good point. If the microbenchmark isn't likely to be even > > > remotely realistic, maybe we should just revert the revert until if/when > > > somebody shows a real world impact. > > > > > > Linus, any objections to that? > > > > We use SLAB_ACCOUNT for much more common allocations like queued > > signals, so I would tend to agree with Jeff that it's probably just > > some not very interesting microbenchmark that shows any file locking > > effects from SLAB_ALLOC, not any real use. > > > > That said, those benchmarks do matter. It's very easy to say "not > > relevant in the big picture" and then the end result is that > > everything is a bit of a pig. > > > > And the regression was absolutely *ENORMOUS*. We're not talking "a few > > percent". We're talking a 33% regression that caused the revert: > > > > https://lore.kernel.org/lkml/20210907150757.GE17617@xsang-OptiPlex-9020/ > > > > I wish our SLAB_ACCOUNT wasn't such a pig. Rather than account every > > single allocation, it would be much nicer to account at a bigger > > granularity, possibly by having per-thread counters first before > > falling back to the obj_cgroup_charge. Whatever. > > > > It's kind of stupid to have a benchmark that just allocates and > > deallocates a file lock in quick succession spend lots of time > > incrementing and decrementing cgroup charges for that repeated > > alloc/free. > > > > However, that problem with SLAB_ACCOUNT is not the fault of file > > locking, but more of a slab issue. > > > > End result: I think we should bring in Vlastimil and whoever else is > > doing SLAB_ACCOUNT things, and have them look at that side. > > > > And then just enable SLAB_ACCOUNT for file locks. But very much look > > at silly costs in SLAB_ACCOUNT first, at least for trivial > > "alloc/free" patterns.. > > > > Vlastimil? Who would be the best person to look at that SLAB_ACCOUNT > > thing? See commit 3754707bcc3e (Revert "memcg: enable accounting for > > file lock caches") for the history here. > > > > Roman last looked into optimizing this code path. I suspect > mod_objcg_state() to be more costly than obj_cgroup_charge(). I will > try to measure this path and see if I can improve it. It's roughly an equal split between mod_objcg_state() and obj_cgroup_charge(). And each is comparable (by order of magnitude) to the slab allocation cost itself. On the free() path a significant cost comes simple from reading the objcg pointer (it's usually a cache miss). So I don't see how we can make it really cheap (say, less than 5% overhead) without caching pre-accounted objects. I thought about merging of charge and stats handling paths, which _maybe_ can shave off another 20-30%, but there still will be a double-digit% accounting overhead. I'm curious to hear other ideas and suggestions. Thanks!