Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2635809rbd; Tue, 9 Apr 2024 12:31:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkeg1F1+XlgIt/EZ7H7EGyji2O3alvqEEGScyJRU8qq52XmZ8DzbbJ5gRtwEwTS8EVxCdxLq7cmKOtQOcPDnmRmzGc6Hv13N3OyfSJ0Q== X-Google-Smtp-Source: AGHT+IF/CUStKUPMSb2f2n4rLyeMPxPl+wUQSYJQWUP0irDtOeB+56asxT7fBUy6LPezQ8UCI69s X-Received: by 2002:a05:6a00:148d:b0:6ec:ed1a:16b6 with SMTP id v13-20020a056a00148d00b006eced1a16b6mr621424pfu.6.1712691064496; Tue, 09 Apr 2024 12:31:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712691064; cv=pass; d=google.com; s=arc-20160816; b=cxlyO1YjfYRokxk81WFm6ACKQsrpkkgEoRPLAccXE5esVFzCQqrZy9bZSz8CJZ7Pr2 k9iufg/aob8CdHpfNlyVTdCIcg4r9mljls5SVIdadG4gPjTnI21X978ENLSFEHJUeCsu piOOrBLrlYgu12IknzjrWuOCJnKwMEjKKcSZAuXtU7ho0kRqvJC92cGK/iqgEzyZJfkC 35DSUcxwjLInb8Pyyzjz73IsOhhroeHdLnUzDG8i4eKWFG0KmomgW+tgcJxSKxTsiymT 8+xxyln4mTLt1HdFyeyxR1NNxfErOIY363KIdehWpw0pcc8P0TZxlcw3AcI46sNz6PRS kpOQ== 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=l2g8VbuF2c0rw+gA2SjXZjA9kizkfkgdJ7YGUNRZUqA=; fh=6UXOkRl8PLWnLRlJFkZ1FKxRpZrfO06mwvecZ/lFyqY=; b=gInqYy5pv/zKMS18LpcF0QTVhYBo088w9KEhmWv+1nQwKTwUiYtCfJUFVn0BMeh1xG nRCZF/zpHtCgCYXN2/vwEjFBNMTaCLaiO84zKzIzvjLTM4N9xalgMM3qV8+9ClZWPIk5 HHYhxY6FJYxrDBeGi/ka5kzIL3OLFFWLMTw+53LHujBmcXHkf/YzGqsJlKeak/sXkbOh zFMV2NwWqoFNJc5mCmlO3zQ594Uxe+vrm3eLEbDLvzed5QnNezCOU0HtkWqtGUUhdYwz 2zzUHeFDkRFkpatYtEtT4ovIqWeMA0Yf4nPyHujJq6Gw34cMQmvnaIOp4sMh6duSLgya 940A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DC8aDXkA; 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-137525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r16-20020a63ce50000000b005dc1bb540cesi9106903pgi.76.2024.04.09.12.31.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:31:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DC8aDXkA; 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-137525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137525-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 05D8DB22316 for ; Tue, 9 Apr 2024 19:26:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A611157A69; Tue, 9 Apr 2024 19:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DC8aDXkA" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 380F01586E6 for ; Tue, 9 Apr 2024 19:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690716; cv=none; b=JyWzV5dgrxZ3zEel9lyo1EAuC4nhsM5doncHyiU9CtbChj1FIGEZfrNHGRFbXMS/vTNLg68MpRS+sB7WHmz4xAnrNNLpb1lNakU3c03L6kUTPd/fPgWvRIxuwQLYRlbYENLBMRwPmG9JSBh+/uJO7AmLMLbA1LMTJdNVnvuyRRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690716; c=relaxed/simple; bh=U2FYI/zDEFEDbvVedqLdfE5jV/TmoU4yobw78EI2s0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pCeS46bKOuttB7bPOp0COJLlQPsLh6s+6Bhi2GCGrGLaTp6EBfTvwh4jfAjK0KbpDxqNIFdyCfbTjXk45WqsnHl3kB0Ib71ZNHAjDZhIbK69/5BKa3hll2PmDe6C9oNAfVkpz1UU0C57zn5awijN3XuxRInYfz76UqBTcn/CMh0= 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=DC8aDXkA; arc=none smtp.client-ip=170.10.129.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=1712690714; 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=l2g8VbuF2c0rw+gA2SjXZjA9kizkfkgdJ7YGUNRZUqA=; b=DC8aDXkAZBc+rAllDUwK8JjAWhnIX/zwt22po0Vtyi/gMIjxo95pgRdP9gk6pR+njYTgCv cCVp6rX4+UpNYSTnOlNrbxAhN8RNe2Vb6aqD7fdMC2zaDATr90Km1yIKEPQCqGNaEDK7lY KMMqS04dKUguOUmOfn7ESKMGfhL6u78= 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-61-9JpVPi_eMcaHlYj18Lcjpg-1; Tue, 09 Apr 2024 15:25:10 -0400 X-MC-Unique: 9JpVPi_eMcaHlYj18Lcjpg-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 9AB78806625; Tue, 9 Apr 2024 19:25:08 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCB3B40B4980; Tue, 9 Apr 2024 19:24:56 +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 08/18] mm/huge_memory: use folio_mapcount() in zap_huge_pmd() sanity check Date: Tue, 9 Apr 2024 21:22:51 +0200 Message-ID: <20240409192301.907377-9-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. Let's similarly check for folio_mapcount() underflows instead of page_mapcount() underflows like we do in zap_present_folio_ptes() now. Instead of the VM_BUG_ON(), we should actually be doing something like print_bad_pte(). For now, let's keep it simple and use WARN_ON_ONCE(), performing that check independently of DEBUG_VM. Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d8d2ed80b0bf..68ac27d229ef 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1851,7 +1851,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, folio = page_folio(page); folio_remove_rmap_pmd(folio, page, vma); - VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); + WARN_ON_ONCE(folio_mapcount(folio) < 0); VM_BUG_ON_PAGE(!PageHead(page), page); } else if (thp_migration_supported()) { swp_entry_t entry; -- 2.44.0