Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp920065lql; Tue, 12 Mar 2024 01:51:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2TJRGt9oEsInexYtmc/0BVokfcQgP6bAUaHx9p+6+O2YuoHAJOAmi/p+51hYsOn/JB93Cfooy3nS4bW610Sw+hhI4u41Xhx4qYpUscg== X-Google-Smtp-Source: AGHT+IFEDartThW+JEYip6wQ1wz01HOQfKl7xLsDZE3Wf9dY309TCBpwla+X3rOWPilBhlv/C4lx X-Received: by 2002:a17:906:b257:b0:a46:2853:5572 with SMTP id ce23-20020a170906b25700b00a4628535572mr3037157ejb.63.1710233499127; Tue, 12 Mar 2024 01:51:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710233499; cv=pass; d=google.com; s=arc-20160816; b=Ei1qIyY5WviDPsiK/RuEKWcVpS55ldV45cw9EZ5i/H9+SJ7L8num3Kwe8hF43zKddi jSC02CO9scXpSWdNtMYQU0vvGqyNYxmaeVYo2Fz2CGbJNpW62uSDKtg908R/6Ns9vRY5 30sc40Fn6vCYLcQu8D/RyRQVInAEZ0fkUsIHYdkvQYBdGQpyM67XEe5ZiAYzV+GTLjXo sJ9s8uPqFJaBIFco0VEqQkgSn6ebuEC/pbuF2o30fq+G3IqoDrqEfUeHO9XkMXFOFoI5 /cO/MZDxjQGErCjAQbC69M8xYnEGTTgxDlOFmRfmDeM6/liINQlEota0UY3/PcaQJWcZ yPDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=6hGVfNscROFvIbtbf1QRwV9VaxAYq7oF5OxLxnQb7lE=; fh=AZukL/spzL0iiMMkH/9O8jge3W6ZZMhmpvWVA5n1Rns=; b=JTKs4kg1KAxCvrXM5xTxrDZMVGJc9lJ3Y3ZYmr2E+fs1EEs9IazR7F/Ff6l9bQe3/r ff2SlrNJXfWqZpIgXy35HxyJDgmhTq4barx2y8AG1EPuLV3dAjKlKT/AtXoIKEesxf32 YdM0nWJK8V2HKS/BoQISgI9SZxF+FDyVsGNjTtjUv4mp5RdBGEOLmbGF3D13Vivb82wB Rf89a643ge660ZnsP7BikZiIrKr7wMYwZJ8ZTzxzDZkTWbuFChpMSeubodUjKKomRi1j ZaKITyQmrQjL5A/bMiPnAJ5iLs2DrViG96KsEQqKleubIICgDbdDFbUYQrw3aI2B5zti IZVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-99970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99970-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ne34-20020a1709077ba200b00a4601f0feabsi3163506ejc.310.2024.03.12.01.51.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 01:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-99970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99970-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 D7E171F21F8C for ; Tue, 12 Mar 2024 08:51:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AB2077F0F; Tue, 12 Mar 2024 08:51:28 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 989E677F0A for ; Tue, 12 Mar 2024 08:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710233488; cv=none; b=slI5q1P+nJ2w2+cJ/FF+5W++XLQbhAI1zAb55fd7VxyNtOFRPAaM9RfUypFtvTlctIDWsnGkvrHBmnXhkIYC0YbSIT8xv0blYWJNOu/C6SwJYiIBb49sfOyXCLUjjavlTYYRaQsNkAvv/wTDNRz/lX8vKXxOqZjGiYA2Ogegxa0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710233488; c=relaxed/simple; bh=wzgtpAlzqAf9lgAtgEoSt+aBjChvRcyTJi+7JedyZHY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=s0tKU/N0ikIDkC7BMpPEg5Ur+Hux6uoa3wnfpeXIHYd+MrspJmMSl4Ax7oPCf9f6iS/G96j/Dzl74FztGvF0rbLAxznoggsJNE+DU/DT+O9ypZBxzkVNW39n/HDwZglEeFsr9YlxjGzpgZP6xvqSC+b/w+3FB/IG5n768BO2bEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 >