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 8C7BCC7115B for ; Fri, 20 Jun 2025 08:05:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 135EE6B007B; Fri, 20 Jun 2025 04:05:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10EA86B0089; Fri, 20 Jun 2025 04:05:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0248B6B008A; Fri, 20 Jun 2025 04:05:19 -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 E4AA96B007B for ; Fri, 20 Jun 2025 04:05:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7767C1401D2 for ; Fri, 20 Jun 2025 08:05:19 +0000 (UTC) X-FDA: 83575043958.30.B73FED2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 75A1A140002 for ; Fri, 20 Jun 2025 08:05:17 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gPqwZLbN; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750406717; 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=FZ6wdfT3r/PmlG/U6lgGdDA1+cv2EsGLU4a4QuReN6U=; b=pU+SSbW8e6IAuMAxO6ws5KCxdayZyvsJDq4IoLrUHO5MNeloSTHubS0vjVfmqMEJTbnhCq 32MxXyigdOOKOyzeHHrq+uHKC2yBTQXMT5K/vLSfc+qhoB8t/O8/72euQjRLZ+oohjYDlf 2mqofCOGNaTFkHSJK2g2xT1hqZOSOS8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gPqwZLbN; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750406717; a=rsa-sha256; cv=none; b=ZMR5BDf5KEt0OtYawxrSb437vJ5XJDABjBGXwL8j/l4JEKyO0+AYtV7yEGdO6meyOGUzzc 2DJkIhgR3TPg8KiKkDX+bjM+DXkRMwW+cxVyMEveZchZLtjoTtfGQhlSEPvko0eF9Go+PF ubGW7QFoyjvHU02o6jLP0Y8yMU0gSe4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750406716; 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=FZ6wdfT3r/PmlG/U6lgGdDA1+cv2EsGLU4a4QuReN6U=; b=gPqwZLbNU/a9trenoWEFXjgv8fvJAakWcP3pLfahWLyIrXIgWM6jHW8bw9R3p5wvYd9oPN TsdKSMvisFshuOeTsGzpdV35A9nX39qCu8EZ2txeVBIYOvB3xaAGgiSyIxM7F2h2FKjHKu LeQcLjipaJr6V9VeLUbDBieVXO+LxiE= Received: from mx-prod-mc-01.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-30-dp5gH5tkOeeOVjixIIFxoA-1; Fri, 20 Jun 2025 04:05:11 -0400 X-MC-Unique: dp5gH5tkOeeOVjixIIFxoA-1 X-Mimecast-MFC-AGG-ID: dp5gH5tkOeeOVjixIIFxoA_1750406709 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 88715195608C; Fri, 20 Jun 2025 08:05:07 +0000 (UTC) Received: from localhost (unknown [10.72.112.28]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 583F918003FC; Fri, 20 Jun 2025 08:05:03 +0000 (UTC) Date: Fri, 20 Jun 2025 16:04:59 +0800 From: Baoquan He To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Matthew Wilcox , Hugh Dickins , Chris Li , David Hildenbrand , Yosry Ahmed , "Huang, Ying" , Nhat Pham , Johannes Weiner , Baolin Wang , Barry Song , Kalesh Singh , Kemeng Shi , Tim Chen , Ryan Roberts , linux-kernel@vger.kernel.org Subject: Re: [PATCH 20/28] mm, swap: check swap table directly for checking cache Message-ID: References: <20250514201729.48420-1-ryncsn@gmail.com> <20250514201729.48420-21-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-R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VXR9a1+wDPtbg6JHWUOxn iFG3aS4h Rp2bgdg7ECb8Rcyfc0oQAaNxW9CZrSkymYVAnycILVNclxlTyKFArFW8QdI8urSNu50YX5gy6sujpjJ+q3QhwtT6U3C73wgO8iPUG3BYWLI/9laOSnfeEAcGqlCmDR5thZ0Mvnv65zcwcD4mgbg+5sV5H9bHMgQAL0eFD0B09WALzBfZX/GYyWtrFhD4OZKfvejCy0/MurRrmBUjcUHaqXBHCGiWn17N3Q9L8VHlHzsT8t5TgZVgB3DEJ/P4mqurbXo5F+XHIwt0NLFZS+5PauxsZsbVq09f4NqwUU8eNuVXLXvzcpzxJx6SAQ+wPwuTVIHZ4AUPeS0f27FB619wdLf9yUWHX1AP6/LFpdSjxNwTkrFK0xuBBgURzfuAkgHjvNyn8wIH60yOUB1V3ow0prr6jLrACvol9yn2kYscXqRrcdEdTYdFCsEQSliA7/xms37nJ+p7qW+uk63YDwBav7+a4TEmgTSMVYen4 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 06/19/25 at 06:50pm, Kairui Song wrote: > On Thu, Jun 19, 2025 at 6:38 PM Baoquan He wrote: > > > > On 05/15/25 at 04:17am, Kairui Song wrote: > > > From: Kairui Song > > > > > > Instead of looking at the swap map, check swap table directly to tell if > > > a swap entry has cache. Prepare for remove SWAP_HAS_CACHE. > > > > But you actually check both the swap table entry and swap map entry in > > this patch, or do I miss anything? > > Hi, Baoquan > > > > > E.g > > > > if (!swap_count(si->swap_map[offset]) && swp_te_is_folio(swp_te)) > > Yes, the count info is still in the swap_map now, I'm only converting > the HAS_CACHE check to use swp_te_t here. We'll remove swap_map in > later patches and use the swp_te_t solely to get both info. Ah, I see it now. That's why the subject is saying it's checking swap table for checking cache. Then it's fine to me, even though it's a little confusing. > > The reason some checks are added to check the swap_count is that: > Before this patch, `swap_map[offset] == SWAP_HAS_CACHE` implies the > count is zero too. So if HAS_CACHE is moved to swp_te_t, we still need > to check the count separately. The overhead will be gone very soon in > a later patch. Got it, that sounds great, thanks.