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 01E16C021AA for ; Thu, 20 Feb 2025 03:24:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86F434401C1; Wed, 19 Feb 2025 22:24:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 81EFC4401AE; Wed, 19 Feb 2025 22:24:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E8314401C1; Wed, 19 Feb 2025 22:24:46 -0500 (EST) 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 4F35B4401AE for ; Wed, 19 Feb 2025 22:24:46 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F191A140A85 for ; Thu, 20 Feb 2025 03:24:45 +0000 (UTC) X-FDA: 83138880930.24.9E77B7F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 0DC1A40005 for ; Thu, 20 Feb 2025 03:24:43 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=by1e4sDT; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740021884; a=rsa-sha256; cv=none; b=aNg7WD88AEongt+ThRta6+hbbtH1tzoZcwut9i8JHpMp41Gdx69BmeNRUdZOoYeiOQSC1+ 26rL3teI9tfX5laGzIvrcFtF9eN5Z1LODOGMcdtph5v/vZD2xaxH3Qh49TYuy8GRG2tuGZ 2hHNiljm4kT2xRwtvL//Hgd2Dze2iK4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=by1e4sDT; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740021884; 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:dkim-signature; bh=YwMMjZVnNw2vA2fx0hn8CT1DbaKYBifmxuPgJ8avEu8=; b=y+EMWLT0655sTS0Ov7wUfOHTyW6nNXBLdqCTEsgx4Imt06n749ZE2Zkts9hHUm5YejuwsN cuh/gWtS+XZJrJgXFsgQnVdEgZVT08n/aY0TrMVnYtynq+4SiaAbu+l1+zIJO86o0qifiq AIo5XlzCvnRPXpTiPau9PRUMgssuoY8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740021883; h=from:from: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=YwMMjZVnNw2vA2fx0hn8CT1DbaKYBifmxuPgJ8avEu8=; b=by1e4sDTFIwylUAlCaa8twr99Z7BAvB7yVezLw4zxRqlhCFBcQgBjUEDkO11LCxdjV98rO gIgKgqLPIaEZy1vC+12NdWIF8DlcWuvjlZ77lCkscuJD4Xxvl3uIMe8rJ2QEUhe1oI4xsh xVZXs4EPMC/m/k5vy5UkI+9mF2NA8zU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-Lz2G54FlNGWqzKqq0g1jtQ-1; Wed, 19 Feb 2025 22:24:39 -0500 X-MC-Unique: Lz2G54FlNGWqzKqq0g1jtQ-1 X-Mimecast-MFC-AGG-ID: Lz2G54FlNGWqzKqq0g1jtQ_1740021878 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0C06619373D9; Thu, 20 Feb 2025 03:24:37 +0000 (UTC) Received: from localhost (unknown [10.72.112.127]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 19B0E1800359; Thu, 20 Feb 2025 03:24:34 +0000 (UTC) Date: Thu, 20 Feb 2025 11:24:30 +0800 From: Baoquan He To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Chris Li , Barry Song , Hugh Dickins , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , Kalesh Singh , linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/7] mm, swap: use percpu cluster as allocation fast path Message-ID: References: <20250214175709.76029-1-ryncsn@gmail.com> <20250214175709.76029-6-ryncsn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Rspam-User: X-Rspamd-Queue-Id: 0DC1A40005 X-Rspamd-Server: rspam12 X-Stat-Signature: n1to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2/ILg5illfbuhdEOwO/CiFpzuZZx+YblVaq3K1tRuKUZ63jO1BYx5MONEPlT0KulCzqLY/TR9rIsxERqEkLTKoOll1hKMjUQM7BdGe0YZBQU3SenWKUaXi6A1H69VTyPnGXKjjtsvJrZYB1XIUfYWVw5laf38jYAYM8NGQoty7iQHlD6kfxbIQzf7MU5m9WcMRpd2ayFm1NWM2Y2sGP4+/NV0T0Rnsa+2hpNKFiRnE/CfT6kn2XbthTjsib17GuIZqOZAd6pPtpAd0j3kwc/nN+JDMLIGfFuvfxthjWbnJeQQI60XL87grJL2+a2WPS+3Eq4+nPCJRooK7uVl42DImP4e/+i/s0OSsZv2liBjQL5nBJfISy1aj/9tllmoDlNnFU5l7RwN31ec/84MQRTIvv6zFXt 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 02/20/25 at 10:48am, Kairui Song wrote: > On Thu, Feb 20, 2025 at 10:35 AM Baoquan He wrote: > > > > On 02/19/25 at 07:12pm, Kairui Song wrote: > > > > > > > n reality it may be very difficult to achieve the 'each 2M space has been consumed for each order', > > > > > > Very true, but notice for order >= 1, slot cache never worked before. > > > And for order == 0, it's very likely that a cluster will have more > > > than 64 slots usable. The test result I posted should be a good > > > example, and device is very full during the test, and performance is > > > basically identical to before. My only concern was about the device > > > > My worry is the global percpu cluster may impact performance among > > multiple swap devices. Before, per si percpu cluster will cache the > > valid offset in one cluster for each order. For multiple swap devices, > > this consumes a little bit more percpu memory. While the new global > > percpu cluster could be updated to a different swap device easily only > > of one order is available, then the whole array is invalid. That looks a > > little drastic cmpared with before. > > Ah, now I got what you mean. That's seems could be a problem indeed. > > I think I can change the > > +struct percpu_swap_cluster { > + struct swap_info_struct *si; > > to > > +struct percpu_swap_cluster { > + struct swap_info_struct *si[SWAP_NR_ORDERS]; > > Or embed the swp type in the offset, this way each order won't affect > each other. How do you think? Yes, this looks much better. You may need store both si and offset, the above demonstrated struct percpu_swap_cluster lacks offset which seems not good. > > Previously high order allocation will bypass slot cache so allocation > could happen on different same priority devices too. So the behaviour > that each order using different device should be acceptable. > > > > > Yeah, the example you shown looks good. Wonder how many swap devices are > > simulated in your example. > > > > > rotating, as slot cache never worked for order >= 1, so the device > > > rotates was very frequently. But still seems no one really cared about > > > it, mthp swapout is a new thing and the previous rotation rule seems > > > even more confusing than this new idea. > > > > I never contact a real product environment with multiple tier and > > many swap devices. In reality, with my shallow knowledge, usually only > > one swap device is deployed. If that's true in most of time, the old > > code or new code is fine, otherwise, seems we may need consider the > > impact. >