From patchwork Thu Aug 17 11:23:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13356254 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 C3C11C2FC14 for ; Thu, 17 Aug 2023 11:24:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE4F0280032; Thu, 17 Aug 2023 07:24:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D93D7940020; Thu, 17 Aug 2023 07:24:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5BB9280032; Thu, 17 Aug 2023 07:24:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B6BF9940020 for ; Thu, 17 Aug 2023 07:24:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 65AC0407C8 for ; Thu, 17 Aug 2023 11:24:26 +0000 (UTC) X-FDA: 81133363332.18.D1A5780 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf02.hostedemail.com (Postfix) with ESMTP id D17EA8002C for ; Thu, 17 Aug 2023 11:24:23 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=VQyIIEXM; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692271464; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=TjcEuXYPc+3P+LflzNgS/R35PrZZxb+MjPLlVSZIGUc=; b=cMeyzWpQd/aqR2o36ZJUsHTW+VyrCcq3l99dCKzGppyB/qTT70HXDPFYDOMXfGSUdVpv1t dmFdakJVJxgwwWFV1OiQ3NokgPH5xMZsLP1ndDvIH57RvBWVO74UBGgzTlFjgANb+o1Ss4 aRCv6QEmN3OUVVYztplTjAyBjub207s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692271464; a=rsa-sha256; cv=none; b=A40yjjvN6LeVhAeqWug8H6VqGW56N7dtYqpoV3dvtgGvjfrA8IcVm2LK09OCFQonia1piA rv9oj1rDR8dYJJpQXJyMRJmXeWQ6zbDl16k+mvXXyFBhtzLgM6e/b4nxi3gEvmI0fL+kXg SIsyIkt8AgSMJtt4hMNmPr6aseSUnBo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=VQyIIEXM; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1bb91c20602so13677985ad.0 for ; Thu, 17 Aug 2023 04:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692271461; x=1692876261; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TjcEuXYPc+3P+LflzNgS/R35PrZZxb+MjPLlVSZIGUc=; b=VQyIIEXMiq6pS36wIOW0IXVYQlXj6t1+KnNqrtLm+JWyhseZuF/zL3mfYeyfkuTkax L2evGQoksYxnfMdnfi7L5aelupBzM9GKiySr4tbyMKg6ti09dvUHMz3K83sLuqcnwOC6 zVhrcmRWkwFwqkOo511Jr7OJuivS8aHsEj+t05Cp5TVi9xMh+ZV1Hl/K1hNUfhJjioSV u8B2KKWIBCJGihrrTPOzc7H9CH4IHP54TtrVh2620huZ9ap2bfecBprTLHC6J6Qv+Jfa lCH0H3x/Qd9cZhCqRkB+y1K0uMDQJXkuZPox9U/8W4MA2XkhKTj+NGusIquX0F6iHqpx BONw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692271461; x=1692876261; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TjcEuXYPc+3P+LflzNgS/R35PrZZxb+MjPLlVSZIGUc=; b=WjRZU4j3Z/BJxz60wTE2/4AXPnjKirRvOmc8KoRrIwfENBzrRj2Zsz2xPIsCEUKGGd +WP7ch/DGs5iFZM5hJQYNggVnsvCRT1199SrnwgGVopDp0ocMk62aKN4tILaXIHBiqXp kA52Xac2LXx8f5CJVxRGR5yI0DDJ6UlyY75Rkx7FzemB5p8jHMEawZEM6PNJyhTk4yCd TOyQZJJwrVGBVqY+H7Q3KlbvPkbBmQv7DprRNQjKNpsPEfrO01CEcOit1U6d3CpQpM48 VucwMIDDHBhXZPRXzct3CyOPOBjYsP6meOIs/BH8rN5NSilDJX+V2k0WexC7PfsAM23P mkoA== X-Gm-Message-State: AOJu0YwXU6Z0Na6aHgQ6TkXHyuBmqNJt7toubM2wFZ2RlFZEQ64fphrL Vfh4bde3fDLv6gq7ee/Iuh5oWA== X-Google-Smtp-Source: AGHT+IEeXBbxeyhPNz97Ub6nYdX4Bl9hgGdsmEb3/sN/aMQfAJ6bX7scVeQIfkeMLyVVQUcumeSs6g== X-Received: by 2002:a17:902:e803:b0:1b8:9fc4:2733 with SMTP id u3-20020a170902e80300b001b89fc42733mr5237062plg.3.1692271460997; Thu, 17 Aug 2023 04:24:20 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id jd22-20020a170903261600b001bde877a7casm7229309plb.264.2023.08.17.04.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 04:24:20 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev, joel@joelfernandes.org, christian.koenig@amd.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, Qi Zheng Subject: [PATCH v2 0/5] use refcount+RCU method to implement lockless slab shrink (part 1) Date: Thu, 17 Aug 2023 19:23:57 +0800 Message-Id: <20230817112402.77010-1-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Rspamd-Queue-Id: D17EA8002C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: x39ma5peen14eqae951bjacjckcmdmm4 X-HE-Tag: 1692271463-646746 X-HE-Meta: U2FsdGVkX19Q2vV8k2SlgaVL/fcVyoWkQq2adPzOx+VsGv3Rp8yIT25cUS5HEmnQ5TJEiAd1LOAnGLLIT9G8KnkYvx2WdOL3rllz9btsVo4Pmb5cnXPF5nH0mCw3Mf7tZ11m6KFD+0gnBRXoM+wxU3SSDQIROOOjRbvKtDAWgRluht+heKcL0IqilFEQVdDHemHw41n8dgkIMnLOWu1sbKOWS1H/myyws0CbKTbQQRRe/fdqook/KQ8dbEXDy5m5RmiGQ71oJsB/cImFCaJDMOV5DteVY0IaJ0mQABHgTCESB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ax6JjXsOIodN9KEZJdI2SScuWem77h8VEx+WvyVgDsHMTsIty3q3QLmOAk33wLLDSbA0IEhPXdIKpf8IsuUFMSri72KmO4JKsIjw1q7HsAOv1QEtVU= 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 all, To make reviewing and updating easier, I've chosen to split the previous patchset[1] into the following three parts: part 1: some cleanups and preparations part 2: introduce new APIs and convert all shrinnkers to use these part 3: implement lockless slab shrink This series is the part 1 and is based on the next-20230815. Comments and suggestions are welcome. [1]. https://lore.kernel.org/lkml/20230807110936.21819-1-zhengqi.arch@bytedance.com/ Thanks, Qi Changlog in part 1 v1 -> part 1 v2: - fix compilation warning in [PATCH 1/5] - rename synchronize_shrinkers() to ttm_pool_synchronize_shrinkers() (pointed by Christian König) - collect Reviewed-by Changlog in v4 -> part 1 v1: - split from the previous large patchset - fix comment format in [PATCH v4 01/48] (pointed by Muchun Song) - change to use kzalloc_node() and fix typo in [PATCH v4 44/48] (pointed by Dave Chinner) - collect Reviewed-bys - rebase onto the next-20230815 Qi Zheng (5): mm: move some shrinker-related function declarations to mm/internal.h mm: vmscan: move shrinker-related code into a separate file mm: shrinker: remove redundant shrinker_rwsem in debugfs operations drm/ttm: introduce pool_shrink_rwsem mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred} drivers/gpu/drm/ttm/ttm_pool.c | 17 +- include/linux/memcontrol.h | 12 +- include/linux/shrinker.h | 37 +- mm/Makefile | 4 +- mm/internal.h | 28 ++ mm/shrinker.c | 751 +++++++++++++++++++++++++++++++++ mm/shrinker_debug.c | 18 +- mm/vmscan.c | 701 ------------------------------ 8 files changed, 818 insertions(+), 750 deletions(-) create mode 100644 mm/shrinker.c