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 05289C54E58 for ; Tue, 12 Mar 2024 07:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749E16B01A1; Tue, 12 Mar 2024 03:54:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F9636B01A2; Tue, 12 Mar 2024 03:54:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E82D6B01A3; Tue, 12 Mar 2024 03:54:10 -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 4DFD86B01A1 for ; Tue, 12 Mar 2024 03:54:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1CFE2160FD8 for ; Tue, 12 Mar 2024 07:54:10 +0000 (UTC) X-FDA: 81887623860.20.2CC38B2 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by imf07.hostedemail.com (Postfix) with ESMTP id 5167B40010 for ; Tue, 12 Mar 2024 07:54:08 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=W40Pldow; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.12 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710230048; 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:in-reply-to:references:references:dkim-signature; bh=NxNmcKhf9PiRD5MQkaPrTZ0o2xgPuVzoEHnYIYjDzZo=; b=UdSjcEKazJhdKQ9oo2XLbNab1qP28C9nt5TPTefKnj8f+6QOpTVxHPubjAvcyqSMhWOy/A ObqbfFwgoCOIyYfYNyXMGUU3DteEGoOwE0rApG8uHUk0KF+5CobF3iUMjXdionYn+xHRho +2zEvsfJRlumGq7TCJlkXWtr09hTuhM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=W40Pldow; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 198.175.65.12 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710230048; a=rsa-sha256; cv=none; b=JvO+stHKdCtMu/STdSvLDwedp7xnZSgCFaL22gehBbjwjIH6y3x546yxXSQOXL7eTpaIjb eCOyQywj2bhP7XmlIt2HxKqVFYhSWkH4OMcF/aw8mb+TPiwldJmmaUXgOYMaBqGJMYUdTY sllqZogySBdLT9kuHcZ+j7LNedXW+do= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710230048; x=1741766048; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=NxNmcKhf9PiRD5MQkaPrTZ0o2xgPuVzoEHnYIYjDzZo=; b=W40PldowCjy4xKJQNB9i71nOW+lS+gY8QkMXSED/bY7E7NIVr0S6XVQt 99OeKCNZLKhV4aC9Nk/ZiBG4tF16GE2qwJBeqOtNyjlUjo4xZS2GjRUwZ CAqS0p8Belb25oPDxI0fI1xhS7VTWvn8qsQ3QeGwR1tzg0sP3qOjrmBUP MApMJJnDlPBIDJvakftQ8zlU2mUfjcov30xTDytu15d/iaENNGPDSgLQ/ OWd+2BuSN/7xUC0k642jDKktekIQNzaH2GsJtAni0XwXBycSmzR3Gm0UD xF/SpXwL8FhNkoaJFepJSNLWI2ndQyc46I+Uuimi6szTDITkakU4jgUVN A==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="16364929" X-IronPort-AV: E=Sophos;i="6.07,118,1708416000"; d="scan'208";a="16364929" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 00:54:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,118,1708416000"; d="scan'208";a="34630087" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 00:54:02 -0700 From: "Huang, Ying" To: Ryan Roberts Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Gao Xiang , Yu Zhao , Yang Shi , Michal Hocko , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Chris Li , , Subject: Re: [PATCH v4 3/6] mm: swap: Simplify struct percpu_cluster In-Reply-To: <20240311150058.1122862-4-ryan.roberts@arm.com> (Ryan Roberts's message of "Mon, 11 Mar 2024 15:00:55 +0000") References: <20240311150058.1122862-1-ryan.roberts@arm.com> <20240311150058.1122862-4-ryan.roberts@arm.com> Date: Tue, 12 Mar 2024 15:52:08 +0800 Message-ID: <87cyrz51lj.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 5167B40010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4dsextj3xfmpnigyqmyjzrq7uwzxek8n X-HE-Tag: 1710230048-728383 X-HE-Meta: U2FsdGVkX19XEyts6XyyVRxA5H2JKWeAjFfdDfJjT9GCGKnSS3IE2Ihbf5guWlZKtx9ZJaYKLp0Wf9dmZjExl3ixopB4RrgNJ+bryNnDVrAPl/kPC2tJONsmLQuJAeC7JANEqNuHRCoQzzYydhWwIM1asEwh9BWk9WPOVc4HFhDkVMIRBtA4dDw8+0cmZoF5ON5pBFA8yn+h+C9S1f3IiEgLhwiOZqQP3ahKQYKs/HtvvUhCuUkYQnOmOikUIk9GssRqfwet0h/xWezak5AVcp7oB01fBtGv8J1uWMiUThHd9ktJxJkQ699kX6PeuLF7TaRzFAKMlZVMxGOa4TFHQhEU52nhrW1dM3/QIDeA6xpyD/pgqLzwiomKFFgxBj+Ptzl459iWupcDkjLngzJ1OzqbZVNUFECRQSleQs1af7P6y/iYWQvzPlhVeXUIQVa7Pyxl+erjrJ178JfHMxvyBnH7d+MvcYVjmDE5BE+6l7IhTas5aJo18PdOXx0hVkVuR/XcNQBhBsRn7gcVuKkcS14HrVlWw2dr+a6IFkap7Qyv+JK041eSsv1tzQMPy+dNXUklX2kLLnBv23t9PI3VM5szDaPbaM0bdripkFYJUgh9NFQxpZlJ9bPKxAZCpfcW1KEMry3nKp+Lsx+7KFBYetWkC6U+7n4nsHh1hWcd8OOGA5Wyi442TFV1+V8EGL0aC0UwHcVmsy4O3PsHXOpr94r1szOB3+vy7Lo9U7c3U3HKf0eqOJNszL1MSQMsPdHE0A99t569Ufx9SRK37NizQqe7/+edv0WOj1epotJ/ZJQzaeEZyACNf5CWzqQoVQ+ag9FZ201/IccbxVFYGXmhSx2OBhGJ09P1tbT7ITFizYyMvt+tQbJij0IJC6dfIy+PhL/7MBNs86g= 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: 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! -- Best Regards, Huang, Ying