Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp672131rdb; Wed, 17 Jan 2024 13:50:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/mMsbpC38u7rnyl6iY4Zxv/U04iCoeIInDarS+Ft6FdKcnKK7H7sEc4kh7HUb6Ic0v1H2 X-Received: by 2002:a05:6a00:1a87:b0:6d9:b264:db94 with SMTP id e7-20020a056a001a8700b006d9b264db94mr6629580pfv.39.1705528252444; Wed, 17 Jan 2024 13:50:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705528252; cv=pass; d=google.com; s=arc-20160816; b=vp3KqFhgHRySZEbTKYNK6cgRm8DgCJGZkCFiG7Dc6Xan6411/llD228g9qHJDcShtH yoG3eubOIm/XHoGCyJZLVPTpDtCvtYi8dZ7qkEIjTBUG+RwOZAMfZwcBzuMGy9zppJZl EgCoKndvT8iu1bPdhwSxxE6Tc1F69GJNY2n/juTZx0/1ge9LXpMYS5r7EPgfbkFHglt5 Sx3f9VgcgweI5xUe5raqyricPgVUIXkckyfZaGCK4L/Dih94K1arulorm4muycb1v6QK Kss37+GXMyMdbs7spi5N4qFW1t6EMZQSE/Hr3F4RtuI8serbXH8nD9ubBF1OzSUTmlJV mxQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=hZH2X8i8fkwb6v6GNbjpSk8FwvFnf/kAGw1sC2lsz24=; fh=kA/T1ijk74x/+Ch6IoPy7+iw7lO7Gg/meAs++deQpx0=; b=pr298eaqo/6wBpDPaHiabZlswwfwzgkC7VFCO6tQX+KFYQvWHAo30fgqKtFhJS+BYD wGsnHIiFX8NwEetOOXay/fGoJ+M1naP6ruAt8QH2ArNLC5Z1IQFPHJc8Z6XqSPMHdlps q0dmUKNisWIE4a4QntDR8EihqXpPdPxB/sJxY2ldBPTbSGkhS1V6PmY0FOLl91pFTP1b Slu2HxQZTnDZLdDMWdH2vC391cIVzcrYYaM4tbtqao7ZS4xFIk8DaxYSq4rhrbeur1uW pdolbumHGxv2kQA61DJqu7HNoWDYzAFodXur/2zQ6i7HUeS39hR58BgBw75VHOxm4fjO YBGg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WKrTihVi; 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-29472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29472-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p8-20020a63e648000000b005cee03a1bf9si253459pgj.448.2024.01.17.13.50.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 13:50:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WKrTihVi; 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-29472-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29472-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 607AB282D7A for ; Wed, 17 Jan 2024 21:50:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEFEE2556C; Wed, 17 Jan 2024 21:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="WKrTihVi" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 4E7F822EEC for ; Wed, 17 Jan 2024 21:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705528244; cv=none; b=pOGwJqq5SKs9rXgDtkuklWggmx7F3+CD0FvbmbYy38qoyI3rdfimLoV4NZrJDKu8PTS08TPgBHzcGsuzBYOWAKxrK/vXELzF9vHgqkI5uj18z6kr/5Q71qIc+aRe8t25w/ixj7m00+9HEUjWl8R5Ie+h4o5Vju0KmIVqh6WhW8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705528244; c=relaxed/simple; bh=tw3Bffx+jXGQej1es+SNpEOHPunpSbyeYD8gKGLR3wk=; h=Date:DKIM-Signature:X-Report-Abuse:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Migadu-Flow; b=BNeGvWhtjsl9IpdyyM3Wybm2xuOAoB5T4qWxI82M9Q7gTmtKZOjJLeUy2v9L1mfgfCguGrsqJVfwStsdKbw4o07ET0yA3PW9c73uDTVH4ohX5exRJcPtMdkKGNHWjXaC97d17y5TgQjzt3jb3l1iQaorpG+9ql+Sw9Ase9Cd5uY= 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=WKrTihVi; arc=none smtp.client-ip=95.215.58.186 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 13:50:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705528240; 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=hZH2X8i8fkwb6v6GNbjpSk8FwvFnf/kAGw1sC2lsz24=; b=WKrTihViJJAbzutckdH2ar3h3Vh3IGlt4SbVr506sVdORjgjf+0prxWLJBSSjS3+v1YPmF R2WrY51IN8wkCcapp5q8uSlxSIA8KusSSq3CU4pkkspKRlVKzpcSEhFnd/fh3N7qhfuN/a kh7pYOsSrqK2T/wLpvrJMMtdbr8Ciyc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Linus Torvalds Cc: Josh Poimboeuf , Vlastimil Babka , Jeff Layton , Chuck Lever , Shakeel Butt , 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=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Wed, Jan 17, 2024 at 12:20:59PM -0800, 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? Probably me. I recently did some work on improving the kmem accounting performance, which is mentioned in this thread and shaves off about 30%: https://lore.kernel.org/lkml/20231019225346.1822282-1-roman.gushchin@linux.dev/ Overall the SLAB_ACCOUNT overhead looks big on micro-benchmarks simple because SLAB allocation path is really fast, so even touching a per-cpu variable adds a noticeable overhead. There is nothing particularly slow on the kmem allocation and release paths, but saving a memcg/objcg pointer, bumping the charge and stats adds up, even though we have batching in place. I believe the only real way to make it significantly faster is to cache pre-charged slab objects, but it adds to the complexity and increases the memory footprint. So far it was all about micro-benchmarks, I haven't seen any complaints on the performance of real workloads. Thanks!