From patchwork Thu Aug 31 00:10:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 13370839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E181BC83F14 for ; Thu, 31 Aug 2023 00:10:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BBA044014A; Wed, 30 Aug 2023 20:10:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76A258E001A; Wed, 30 Aug 2023 20:10:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6589944014A; Wed, 30 Aug 2023 20:10:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 56B648E001A for ; Wed, 30 Aug 2023 20:10:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1071C14034A for ; Thu, 31 Aug 2023 00:10:11 +0000 (UTC) X-FDA: 81182467422.18.644C160 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf16.hostedemail.com (Postfix) with ESMTP id 531F1180009 for ; Thu, 31 Aug 2023 00:10:09 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf16.hostedemail.com: domain of dennisszhou@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=dennisszhou@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693440609; h=from:from:sender: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:in-reply-to: references; bh=B0ifgTXq+r2BeSdkqHGP0xQUpC4XvAwiwkMVFgeOVjg=; b=fhiDugnNHEfr1FPNLhdkdd+qkfmwxtZqwcw6GxqXjtyJTE1Y6MMPjFINFKv3kn5gVmxHcx MxZkyEbgs3VdTMYpQ9Y+LALcVyxXRjcZXD0fTPyA+gsIJOxhllK0xqIIFyR7RNVxJI62zZ Gi54OciDHWYcqF4KpMTvSptFtSC16DU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf16.hostedemail.com: domain of dennisszhou@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=dennisszhou@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693440609; a=rsa-sha256; cv=none; b=AOj/2Jhwf6iYqRBbL5D0cbFgDcuS+KQ6xE57tE2Z19ZucD4AVhaakKBMLUx1UovUlXn5N7 uIkeLfP11RzKNdruUjNg6aIlKYNvFGIYnoDOeOReFPEo8wefHZImUFjLfR742IRBMzWvf+ T9+/IHG7AP+3VrvyKmblgNYmFD3wB8Q= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1bf5c314a57so1671545ad.1 for ; Wed, 30 Aug 2023 17:10:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693440608; x=1694045408; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B0ifgTXq+r2BeSdkqHGP0xQUpC4XvAwiwkMVFgeOVjg=; b=VgE+CtJv+1Js7gOloCr8j42h5xoPXnXqwLmetof3Zt3w8lVMzOWYR+yVz6r5SUzfgv v+1yhwGZIcEjn2Z4Mk0V9hH6AjrATTsjdfm+Th5OHDFJ8hiynkwmsWOy4cK6fVy0IUBS baFLREjowVN/957RV0PzSU12f/B0wAq26WRdTzzMEw6xVwEr/5I4crVwZFrCAYjU43D6 JdcvOl8IPeJh7BWEuC9Pk7JO4/AfYqtxkrZS1tlwC7jYG+yz14N2wd0mjFickckw1Mij xDARXBuJRqpMlop3dqVjPLe2R7FgIrc2JLyIXPVWsCdZhZjE+HMYWYL+3Yi5bsZm1xC+ 7nMw== X-Gm-Message-State: AOJu0YxDcmoFrcp3ImO7XBJx3eDW/5fme9SqMXIpAIgOh51PauBG4IiD w+q8hX2cygkqIsqhjBdvlZ0= X-Google-Smtp-Source: AGHT+IEqI9QWZA2A4KOT8unleUiNW2sL2+SI9SHiSKYx3xYHKp4DwZtEpxLuVjX1aR6Ka/Vqyh4NfQ== X-Received: by 2002:a17:902:a5c7:b0:1bf:13a7:d3ef with SMTP id t7-20020a170902a5c700b001bf13a7d3efmr2731095plq.66.1693440607918; Wed, 30 Aug 2023 17:10:07 -0700 (PDT) Received: from snowbird ([199.73.127.3]) by smtp.gmail.com with ESMTPSA id g15-20020a1709029f8f00b001b895a17429sm68225plq.280.2023.08.30.17.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 17:10:07 -0700 (PDT) Date: Wed, 30 Aug 2023 17:10:05 -0700 From: Dennis Zhou To: Linus Torvalds Cc: Tejun Heo , Christoph Lameter , Mateusz Guzik , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [GIT PULL] percpu changes for v6.6-rc1 Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: 531F1180009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: tbyoynprgidhr38fb75ek8b9ebtzt5fj X-HE-Tag: 1693440609-286280 X-HE-Meta: U2FsdGVkX1/6Ehaf49P5/qsbFrCJDszMC6ZAwz/DkRi3q2Fb4XNJk1j8YHiRoUw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f48iqfvouObv6fxt5XYeQBqEw0UJ7OT5o2bP8LOpaz2UnwnFMUbBYCWa/bQBkGGkV3cWsooAv5T7hl/VcLjIEKlUdHfxFNC5DHCL1z9E8jlW5BkZII+uRcRcnqiBsA/IrCb2z/eHQnvZYes1a9xjjfNQIQbUAWXsmtOCpaauMokYP1c79iTNnlG5XF5aL6VUW91XGZRjeY5fIXbXqlwIQ3EVRgy0vOnURfC0sSVsiY6hlwHnJwQHW4g3UWVXpyfzfTlQg9ot1lFu6A+uUk0lxEcCVTACNrlhqxKdI1JWty/2RE9pYbmZBXmk/jbBDktFB5edce/cBjiX0Hba6C5vvU4uzV/afyuS7W/XbZC0ktNaE8T8vVqmvqzVVbqbcv/e6Y85qbLv0d12Xi5Nm2JOB4= 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: Hi Linus, There is 1 bigger change to percpu_counter's api allowing for init and destroy of multiple counters via percpu_counter_init_many() and percpu_counter_destroy_many(). This is used to help begin remediating a performance regression with percpu rss stats. Additionally, it seems larger core count machines are feeling the burden of the single threaded allocation of percpu. Mateusz is thinking about it and I will spend some time on it too. Thanks, Dennis The following changes since commit 5d0c230f1de8c7515b6567d9afba1f196fb4e2f4: Linux 6.5-rc4 (2023-07-30 13:23:47 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git tags/percpu-for-6.6 for you to fetch changes up to 14ef95be6f5558fb9e43aaf06ef9a1d6e0cae6c8: kernel/fork: group allocation/free of per-cpu counters for mm struct (2023-08-25 08:10:35 -0700) ---------------------------------------------------------------- percpu: changes for v6.6 percpu * A couple cleanups by Baoquan He and Bibo Mao. The only behavior change is to start printing messages if we're under the warn limit for failed atomic allocations. percpu_counter * Shakeel introduced percpu counters into mm_struct which caused percpu allocations be on the hot path [1]. Originally I spent some time trying to improve the percpu allocator, but instead preferred what Mateusz Guzik proposed grouping at the allocation site, percpu_counter_init_many(). This allows a single percpu allocation to be shared by the counters. I like this approach because it creates a shared lifetime by the allocations. Additionally, I believe many inits have higher level synchronization requirements, like percpu_counter does against HOTPLUG_CPU. Therefore we can group these optimizations together. [1] https://lore.kernel.org/linux-mm/20221024052841.3291983-1-shakeelb@google.com/ ---------------------------------------------------------------- Baoquan He (3): mm/percpu.c: remove redundant check mm/percpu.c: optimize the code in pcpu_setup_first_chunk() a little bit mm/percpu.c: print error message too if atomic alloc failed Bibo Mao (1): mm/percpu: Remove some local variables in pcpu_populate_pte Mateusz Guzik (2): pcpcntr: add group allocation/free kernel/fork: group allocation/free of per-cpu counters for mm struct include/linux/percpu_counter.h | 41 ++++++++++++++++++++----- kernel/fork.c | 15 +++------ lib/percpu_counter.c | 62 +++++++++++++++++++++++++------------ mm/percpu.c | 69 +++++++++++++++++------------------------- 4 files changed, 109 insertions(+), 78 deletions(-)