From mboxrd@z Thu Jan 1 00:00:00 1970 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 5BCC3C54E66 for ; Tue, 12 Mar 2024 08:51:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E735A8D0021; Tue, 12 Mar 2024 04:51:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFDA58D0017; Tue, 12 Mar 2024 04:51:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA0F88D0021; Tue, 12 Mar 2024 04:51:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B77788D0017 for ; Tue, 12 Mar 2024 04:51:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7D05DC0FEC for ; Tue, 12 Mar 2024 08:51:28 +0000 (UTC) X-FDA: 81887768256.07.5CEF6EA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id EAAAD40005 for ; Tue, 12 Mar 2024 08:51:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710233487; 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:in-reply-to:references:references; bh=6hGVfNscROFvIbtbf1QRwV9VaxAYq7oF5OxLxnQb7lE=; b=edq/yDx5CBwGMcILIomIgLqBwm3CcIpxzhbe5sHzGXEi5FYOQEjz7zwm61hrMd02mxxrCb E2dJEMPgQ8GN/8CfrJ1nPGbsav6yMRq5FX/koz4KLUtc4PqhK7zRgf2bDrbexnL1X31o21 N7k+qghyP4CA0PrgqL15Ck6pqQ8xNmE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710233487; a=rsa-sha256; cv=none; b=yBxDnTcrJoiCrVT/vGLCC7bGn2b5wRrPDFnxOpxZucQAo6kah4jQzudcHeULqXaDBpAVHN PZBq9r3EyGsOWoZTmkWnvplBK7grLYYW3YcOm0FcNng/j+5Pahx4iQuvu84hZxIdtEej0s LsU1S61e6GKoTIeIqY0WaKOdDPwxX4U= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E19401007; Tue, 12 Mar 2024 01:52:02 -0700 (PDT) Received: from [10.57.68.246] (unknown [10.57.68.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8CEDA3F762; Tue, 12 Mar 2024 01:51:23 -0700 (PDT) Message-ID: <2e236d6b-e6fc-428a-ad06-c2fb1dbf5c8b@arm.com> Date: Tue, 12 Mar 2024 08:51:23 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 3/6] mm: swap: Simplify struct percpu_cluster Content-Language: en-GB To: "Huang, Ying" Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240311150058.1122862-1-ryan.roberts@arm.com> <20240311150058.1122862-4-ryan.roberts@arm.com> <87cyrz51lj.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Ryan Roberts In-Reply-To: <87cyrz51lj.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: qb68j7em43y3tenrpfbanj7qt4o8swfa X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EAAAD40005 X-HE-Tag: 1710233486-441721 X-HE-Meta: U2FsdGVkX19cXUxQNQbq7+KYedl+GMH6AVlRiQQWbF6iGWajybBF2voiRi8DExOuMZpWFdRWt3+Ee6uk31jjk1NpwayIbRc0j7kpzHcKzx02WmoKA7vUmQR7WbLWrgF1t87XIyc8qhZA36XkZGTnB4IAlmpfIIKqapqojv6Oe5u6EqHzDav3qqojfb5o2jO5RK/xSnxdwAg1KQKrXgrbVIs1T1Z5VEzbPxNxtnzlQax10G8dDWXePEHnv1V/71+JnZJu35lJYDqkIgLAHFY3lYms2Xb1ODq7z/skzlg0jSGjEhAz2zTmLN7QTMWEfnS0DvTlvhXsAmWzdoS18xVW6LyFdDkB8NO9zP9ZBbE0lLYK5mRmhlt+C70gtBfdypQPKZFjDc+6ky1M+uquUv3S6Y9NQ4UWNmbLnS8kbNzeMVU2v0CFSOPzIy8/lam9YGAqTbJZ5bwyxZ8OH7DEOXbNC01i7N/ZmiVaov1pUGtyXvKYYX8xqG9ZuL4ThGPRMjraD1D69txJS9pRWKISYAYi7QR6iRz4QAvsVtINbQP0slb9KCAkw6a/g7Sq/nizWGEXfBofYAdBfLfhRpfoxajQ6isw0fZvHHx8NZnF6dMH4HL8NLWQYa9Qq/0+gcYm3S1YEY+B5nFCe1NDfWRPe8abMxgdX4XhdfWz6mK2iIvDn3IWGGv4dPhzCHUJeDGq2C5I4bBtBDtGfgMAVaRPOPFxhLsnlpUMpxIkAb9hy62PtAHdz5bpIGjTwj2M/lolJ5Hh8RnYZcR4LRx28Lm99YJZEC5wkQbBQfcJtbKHi4OJ+9cQapSpN3wQ8Hrhje/EmghnS1wKWbn1aVsOw1eLxw8zH8VO0NriTNf0A+WLDovwoixI9OiA6pBTo6oRh+XAixTw9WAuP0MKWmA= 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: List-Subscribe: List-Unsubscribe: On 12/03/2024 07:52, Huang, Ying wrote: > Ryan Roberts writes: > >> struct percpu_cluster stores the index of cpu's current cluster and the >> offset of the next entry that will be allocated for the cpu. These two >> pieces of information are redundant because the cluster index is just >> (offset / SWAPFILE_CLUSTER). The only reason for explicitly keeping the >> cluster index is because the structure used for it also has a flag to >> indicate "no cluster". However this data structure also contains a spin >> lock, which is never used in this context, as a side effect the code >> copies the spinlock_t structure, which is questionable coding practice >> in my view. >> >> So let's clean this up and store only the next offset, and use a >> sentinal value (SWAP_NEXT_INVALID) to indicate "no cluster". >> SWAP_NEXT_INVALID is chosen to be 0, because 0 will never be seen >> legitimately; The first page in the swap file is the swap header, which >> is always marked bad to prevent it from being allocated as an entry. >> This also prevents the cluster to which it belongs being marked free, so >> it will never appear on the free list. >> >> This change saves 16 bytes per cpu. And given we are shortly going to >> extend this mechanism to be per-cpu-AND-per-order, we will end up saving >> 16 * 9 = 144 bytes per cpu, which adds up if you have 256 cpus in the >> system. >> >> Signed-off-by: Ryan Roberts > > LGTM, Thanks! Thanks! What's a guy got to do to get Rb or Ack? :) > > -- > Best Regards, > Huang, Ying >