Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp898714lql; Tue, 12 Mar 2024 00:54:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+mWTsOyzcNS4YZfo5s7zoU1uKoTmjnVjbVYa3xmWb+zQqv/Sb2WBQ47WBn//c+X5kJgbe6SYh5z1XEqwQ+9MB8xB9TGCK3c+xIqNCSQ== X-Google-Smtp-Source: AGHT+IFcjTTxZHDz8EzKrXnorBJr+lmAxXwbQ12uNeCqnY48vmRB9KX4X69dh+CfSstyD/a8kxJK X-Received: by 2002:a50:8e17:0:b0:565:6c72:40a9 with SMTP id 23-20020a508e17000000b005656c7240a9mr5425784edw.28.1710230062004; Tue, 12 Mar 2024 00:54:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710230061; cv=pass; d=google.com; s=arc-20160816; b=NMTrqdr929QeF/cxFi8NtbN5GrtZJNjPE4BnsUAtH0ECd2Nm5Ctra0xB0rnmiohmWg N8+pjPuxxkxY59qF1n4AvN/T2Y4Bm6p+KdRpYd/HDuhaHHSu83WaWNCbtu6r4TX4IX3k IEaNAmMrN7+6X4NUrEeFJwgUYdf+yjeQbVq/SJVj2WUa2ymXOD4jN4hVduvWep3cC+yI 15HikfU9VGxPVOucuh3RsZmb4wd5sy+18mvneo+A78/5JDnH2DP0wZxqx2JDXH53ceVa fFAMttDDiIjOv5DkxOOhiCLfhJAYJV74DQvu86qYxqeNy0ixb8qeWHOKJ5DtxR83hd2O Lo3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=NxNmcKhf9PiRD5MQkaPrTZ0o2xgPuVzoEHnYIYjDzZo=; fh=wfcGb27y55Qic+8hN/vldt97uHFOgVim6iizhmNvH9M=; b=xqJLZwe2xeBX4ZdWLb+ie7YAyIsXDWBbSBg8FPnpZ/m7zIaX3RcV6BOLApmhIcOsnd PcsiVOxyKYPTUxCU+3GSZbW9kTO1Q/AuQbYUmHElGjHsTdr0Ss9Y80O5sOVM0LuzgTl0 WXB+IxAdt2BZ3L6Sp03hTDMzggXayEQJXJVDklL55P//o35RjRna7LXu1gCg4rYxnOF+ aJI+ccqAcqbmRlAcJOkF6DnHOFDkXKOY9DbF+Jyty06USWtHezzVdM1TjDmLy+zaB3C3 1icFFtmD/wPXrn6xzefc8LSvm1Pw0iYwUVPdOzUM7BSeoM55aNfdu2pwABL5kKBqWtXC rwbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=immu3X6c; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-99926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z14-20020a05640240ce00b005683b59e5c5si3149895edb.28.2024.03.12.00.54.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 00:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=immu3X6c; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-99926-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 66CFD1F21AEE for ; Tue, 12 Mar 2024 07:54:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5795469D07; Tue, 12 Mar 2024 07:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="immu3X6c" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 CB69F6996F for ; Tue, 12 Mar 2024 07:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710230048; cv=none; b=mmV263KiCwsMMRpf9mgvswIe6OkjBI/212RGKxXq6nRdbmYqukfLlAs+Vt0Ey8dxFLwFXyQyv4v6Sh51Ri7YqLpUoxK0xGnJB4QZjlFRWQ9LkS6HTwwCOpdlvni5FF9BfFwU+V2l39V/QiSbG3s8dX9hO11owp+IasfuHLTxkqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710230048; c=relaxed/simple; bh=NxNmcKhf9PiRD5MQkaPrTZ0o2xgPuVzoEHnYIYjDzZo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=pbKNOSFimCP0PLiBmkGhJX6wizU/GwI2oslciZttlswmm2QaoDgLDX7t4VN5bCcEXCjDJNsbIJ/4nmBRBapes65oZFIqRszwHrZRhz0GXC7BJ/YfMxgAu5d11DhiOShsXojE6MNye5pczS6W6hgeYGH8HNi7fLkKCpZ4kqInA7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=immu3X6c; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710230047; x=1741766047; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=NxNmcKhf9PiRD5MQkaPrTZ0o2xgPuVzoEHnYIYjDzZo=; b=immu3X6cP0BEgXSBWBXgXsk7Iu1eyG8mmnej8uk1nyT5ERReiSNrUwu7 FTlRzwloUU178WAnpC1EadFM12Cwe0JfNfb+YpGAm4X9AJJZ88fVPpVcw /QL2NRjOVqCTFoUBaDsDrM0SVvgk9hyL+tF/giZRVyD0KcTVuyLPD7TZA vi4zLUeXOBXgrtd6p2NStKbCQxz/+T3B6JMzSPcG2S0DP0SpaW84J4fpC FBBnTEMrTiBfYz0ZqnbxK3g12PCZ1VLr7CZIjJ/djIlbGHnHXDv9tV+Np jPdO/3e0Jtl1KDnOIupTkb+uK7CeCoYq/S6lHLoJsZ6wQ9b4z8g39dgwu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="16364924" X-IronPort-AV: E=Sophos;i="6.07,118,1708416000"; d="scan'208";a="16364924" 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) 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=ascii 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