Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2635184rbd; Tue, 9 Apr 2024 12:29:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzFEH0ZH/JBr+jXP8ViKJDa587Jotc/jfsmFBaLnwOVRgfuBIC/TogEp/mRkWHjjSt1lfwu8zf7di9rqn9rcgvMw5pQ6dsRIV7MeEyPg== X-Google-Smtp-Source: AGHT+IHoKRnXbVrhPl24N/I4NZBoYYBKueuTgR1KW1iX1qnNtl2RfqVpZ9sYZM8Ii6dTxgZTzngF X-Received: by 2002:a17:907:9725:b0:a50:9190:b751 with SMTP id jg37-20020a170907972500b00a509190b751mr367118ejc.10.1712690994735; Tue, 09 Apr 2024 12:29:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712690994; cv=pass; d=google.com; s=arc-20160816; b=WqC1BKo/jpoUfzpos8lzKZOz8ZU3G3qed0393PcwsAglJJ+5F2LibijVfJ3SA25w2X 4DLbKcbD9LaETaoifKB/RH1SM750qUgKIrWu7lRrxSl06HoK6bEaxc+bMiSYhvvCGk0O CGSh4hZbsGRV8/A/2qb2eTpmvzTlXFZtA7rSxvjMuH3RLETwMzRp1Pml/anls3fY5lrl dR2zO3I1W2Q4AQG6VyS1ssywtobMxltptxR8zi64IOi0n/9SgsC0E9akOPMGGkr1Y0kJ kmJP5MdfX20EB0tYAYP3D5GfnuIYL7LmNRBkCJRl3mi022UnJ3Xptf41bCW3blDqyv0G B+Ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NFT5r3M4f3jd1xpIDzMU21YnNFkRRFHEv0eJ+fAnhKQ=; fh=6UXOkRl8PLWnLRlJFkZ1FKxRpZrfO06mwvecZ/lFyqY=; b=R7KBaPr3VY7g1mPTFYKf7cc0AsEMH14sXQ4JyS41jnFvuTAmA89wGjTBYU33/WVt6/ Bw7P9jQjRJ/ZDhScbRvxhVC3CDK8RUNs9jsQVvvwK+2MoVzU21/cfNMX3z4/XISm+aHh odeA6t22DuvAYlP2H92CC0F/zSGlXoNdUx2Yga/tL7aeMIgm/ZptLH+qghV0nyCi3Doz wyR/FOybieok5j+x1CgX7slTXusdtJZzDNazCJP0mj8UUiYvKmjO+aAb/YoSKy9SsB9l E6HTCFjscs82tfDrOufPaIo+B8N7fgN6u3HPaJuKCfIO6WXa71cVUt3iUZRPY/eOc302 Kawg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MoZfT7Bb; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ka3-20020a170907990300b00a51a6c09d37si4749615ejc.557.2024.04.09.12.29.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137535-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MoZfT7Bb; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 7E1D81F21A86 for ; Tue, 9 Apr 2024 19:29:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB2581586EA; Tue, 9 Apr 2024 19:26:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MoZfT7Bb" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 6A91A157A5E for ; Tue, 9 Apr 2024 19:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690810; cv=none; b=bMMtrPPMwRp6UMxJyqvaa3aR4F5NXhV7GoFJzbYb/eh4GDFgTJbR+89msrssgcrZ2Ai8EyflFqQQHDvp4eUOvDgIksnC/i1fucMTgvVKbrqNXRlpEMVs7C9eZom3LKgVJ+mlJb4tuJ4bWPQn3NwVftojyV7f4qVXk7YpTY5J1wQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690810; c=relaxed/simple; bh=a+SVwgdqFyED+L8M3oTlZBiNzAQkOllWBVsreg72suk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lOIoZy/svPIZyzG6cWe1FFxzfCOS1KIf+fWoboC90iV+fE818LXiDrNuAKXQHVTqAwecunjyEI9Du+7qqVyGALW+Nre7seBIl241pmo+c11CZWLOsrL2jFhaj+uC+buHrL36Atn3bs747SsSK3D90O+GMRRIa8fdXExWxYZMWeE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MoZfT7Bb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712690808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NFT5r3M4f3jd1xpIDzMU21YnNFkRRFHEv0eJ+fAnhKQ=; b=MoZfT7BbkVFdjihTJtYi5xsmlRFK4ypACmsdUOB2tt8uEgw7UdEz26X3zplCeDMkToEfWz ebvjjRliBDf7F0ZgNDSK3ZGfNed1goz9b6S+pOWl54ULbmdCwxqxpoqju1Sy7TBXnbXbA6 FroTmbvtJxVyfopaGuQ0eedrzAexFT0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-WsCdNN_cNKiuXalsvr_glg-1; Tue, 09 Apr 2024 15:26:44 -0400 X-MC-Unique: WsCdNN_cNKiuXalsvr_glg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89ACA811001; Tue, 9 Apr 2024 19:26:40 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BA6940B4979; Tue, 9 Apr 2024 19:26:28 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Peter Xu , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan , Jonathan Corbet , Hugh Dickins , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Chris Zankel , Max Filippov , Muchun Song , Miaohe Lin , Naoya Horiguchi , Richard Chang Subject: [PATCH v1 16/18] xtensa/mm: convert check_tlb_entry() to sanity check folios Date: Tue, 9 Apr 2024 21:22:59 +0200 Message-ID: <20240409192301.907377-17-david@redhat.com> In-Reply-To: <20240409192301.907377-1-david@redhat.com> References: <20240409192301.907377-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 We want to limit the use of page_mapcount() to the places where it is absolutely necessary. So let's convert check_tlb_entry() to perform sanity checks on folios instead of pages. This essentially already happened: page_count() is mapped to folio_ref_count(), and page_mapped() to folio_mapped() internally. However, we would have printed the page_mapount(), which does not really match what page_mapped() would have checked. Let's simply print the folio mapcount to avoid using page_mapcount(). For small folios there is no change. Signed-off-by: David Hildenbrand --- arch/xtensa/mm/tlb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index 4f974b74883c..d8b60d6e50a8 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c @@ -256,12 +256,13 @@ static int check_tlb_entry(unsigned w, unsigned e, bool dtlb) dtlb ? 'D' : 'I', w, e, r0, r1, pte); if (pte == 0 || !pte_present(__pte(pte))) { struct page *p = pfn_to_page(r1 >> PAGE_SHIFT); - pr_err("page refcount: %d, mapcount: %d\n", - page_count(p), - page_mapcount(p)); - if (!page_count(p)) + struct folio *f = page_folio(p); + + pr_err("folio refcount: %d, mapcount: %d\n", + folio_ref_count(f), folio_mapcount(f)); + if (!folio_ref_count(f)) rc |= TLB_INSANE; - else if (page_mapcount(p)) + else if (folio_mapped(f)) rc |= TLB_SUSPICIOUS; } else { rc |= TLB_INSANE; -- 2.44.0