Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp651464rdb; Wed, 17 Jan 2024 13:02:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEb0E1Wbxdb43FtFl2jLsT3u5q2jicXFZUou8buCidXeSQfKIDq5XBydFc7jZ+br/T1Ua1Q X-Received: by 2002:a05:6a00:2354:b0:6da:7ea8:6210 with SMTP id j20-20020a056a00235400b006da7ea86210mr6657180pfj.14.1705525364087; Wed, 17 Jan 2024 13:02:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705525364; cv=pass; d=google.com; s=arc-20160816; b=U99FSwl5J1PLr6zrFtvff9qcrIe9m3xwLtl6nRrCbMF8X3uXVSJXFqu/5autXQgyU+ 2nFlQyVjjbDYpiI/zMwbEmNVSqNwdtxZIGu0L3g03eV1Q8CFPuxW29CTzHUDHCr1nxjU jY5NtxfXs0K4jg7EnKgrMsHIDuZ2ksKzAWyp0YFYn/Gc2r2MB65DFRLY+kTNUCqEwSw7 6mzBIDPFns4jtZL09w0md1NL3Z9rCvJXZjUOQbJaexBGdP0hY0AP6RuSGOiTO6L/6bPi BDxbiLXKZoINcDeW1TLarHimzGsCfRKo7SohjW1hD25+OJNtaShzA8mHHBjtw0lLxVD8 YOAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=nsaUVhsK+enKkBw1KIJtxzFPjcPyIBpdkEzOvagjDdM=; fh=fBTU3DxxbNzlnllLX0K/oiS2MRIyJTcsYwk/Gp7JGlU=; b=nTizSme4bFYUPoU8RFza7qXhonQh3I6b+mFGFkor4qOFKoQ4S4RJtUBGNnPGKxHn2F cZBSa+hjawWoJxdFAqMpQdO8RwE6DYVxjOAyf2hWq4tqeYHUIiwP1whQDVrQORZ0YcaY tVvdeuURcggGihUHRZMGLMOpqVpdyiKpBmXb9GhOiV5EgzZ5MCF5xYBSchY0yXcJDewU rYPIoM7Z/rkpKQD6p7bGukdlzIUc6yxlUiEBf6XapATVgyPzEZbUmuQyvORzG6X13dIL MXlqDk+2PSvkncF1ooUUXsmriItarE1XbXf1GdKmdXIPX6N8+iZmxqovVhAVVfRxH+mO BrcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TjrrNFBf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-29444-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29444-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h30-20020aa79f5e000000b006d6faec9bf6si2391950pfr.13.2024.01.17.13.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 13:02:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29444-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TjrrNFBf; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-29444-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29444-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7C212B24049 for ; Wed, 17 Jan 2024 21:02:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0EBB25562; Wed, 17 Jan 2024 21:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TjrrNFBf" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86A7B24A18 for ; Wed, 17 Jan 2024 21:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705525353; cv=none; b=UjzkBv8F3a/3MwSJLGdbJvAccHXipKqEBvHKNLYVSoaKAROHoQzNMLWYdb+dyvAs9TCCk2Cgtn+IiE20rlLVYRfFhIgIL2J3UXV0fZtPZ1GulccrzgoGGQNDIbdsZozGN1RZVQVOlKW7iUl4e1jWQt3VsXjTEvxkY6QS3+xH2kE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705525353; c=relaxed/simple; bh=x2ltNTRVY40OZPPI4mwfRvVr6yiGl4dOpCTU/Sebxb8=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=qX5VPmnGV2GkcrNcNhKRBJlQoPyYbOVaOIToZGKl9coPEELiMfs+pmjgs9ZhPt+eydmziqnyInTyelybQnDk1sHsTre1KDIBkGF0ckFttFU22jB3g0QRY/WVUp+WAdF7VPeTdpIZdLUF1PR/AodN9GwX3fRB0eo4k+drYlLaSZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TjrrNFBf; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d6f1df9355so151365ad.1 for ; Wed, 17 Jan 2024 13:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705525352; x=1706130152; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nsaUVhsK+enKkBw1KIJtxzFPjcPyIBpdkEzOvagjDdM=; b=TjrrNFBfTNTDBlHsEIFwOR9AmuxRwYRzYW0Zg2PtHW6FqeOV8A2oh95y9/OotD7tLu n6po1eHC/V4H/2rfP4nDM61zILpMjSrRTHfoxdnFF0RTtVp/248GhZWi28E2/sUi4Kcx RQ3L20VF3JQrZ4tW28olUr++xCz9QPD3L8d2ZrlE4GKV7cFPbsQRcHc9xAxSflko7ctE cCnxuXhIw8jtk75Uzl6AR7LYoSJSpOu3K2j9AA6uHacOInofDMz004lriyb2u4z7SL9V XVFooG3L6LK6Wpk4/vskvNe1z9Y1FEUeZzLNT2NEjmj3wgVAQobIjx5vF8slzrp8XSVF rlfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705525352; x=1706130152; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nsaUVhsK+enKkBw1KIJtxzFPjcPyIBpdkEzOvagjDdM=; b=leYM0yujrFnHuAzooT1n/m9/7FldapFVdMSRD7hVz1n2+/wi7cquIZA/E2WYtT+dIs 8Q3+t0R6YR4Ril2yLISaVWESiqS+wSaApj67n+VaJLvM+9GSjCFCxwrPTN4Ulzop1JCJ zQ8AJ+kwM19BFwBNHSqljJRpR+XXqiN3nYsOZ+7aenyjOSM0NjtmmppSwvEe8GrQXWRf aolkVkBmTbd0wWHYqwgAoEW7sku0Rxq0jq7Ikc6O1nnX+fOitlV1J2MSr6wlRse31ULt rAII8SLr43N/Ev675Ez49/w4sINLL+LAfS9Ft7+TVLtHnUxIBVwo5Kf6y9Dssnpq6b12 ucMg== X-Gm-Message-State: AOJu0YxElDX5xno2T1Xq+Y8kRGts5KyKak7f3Di0atChvRZp+N+R74ec qCcmHDeXruTfLbTR4noM4S8GOWn3zVKQ5OflIOtum49/+LZHChGT2IZyRq+Aoj3OxRIvFSGsrYF 1aiFuIi3WJXbYYe5NCEnrlLogFQkH8h3Y9JDk X-Received: by 2002:a17:902:aa98:b0:1d5:b931:911a with SMTP id d24-20020a170902aa9800b001d5b931911amr234007plr.27.1705525351695; Wed, 17 Jan 2024 13:02:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <6667b799702e1815bd4e4f7744eddbc0bd042bb7.camel@kernel.org> <20240117193915.urwueineol7p4hg7@treble> In-Reply-To: From: Shakeel Butt Date: Wed, 17 Jan 2024 13:02:19 -0800 Message-ID: Subject: Re: [PATCH RFC 1/4] fs/locks: Fix file lock cache accounting, again To: Linus Torvalds Cc: Josh Poimboeuf , Vlastimil Babka , Jeff Layton , Chuck Lever , Roman Gushchin , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 17, 2024 at 12:21=E2=80=AFPM 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/whe= n > > 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-902= 0/ > > 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.