Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3908025pxj; Tue, 11 May 2021 14:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCkIxBk02WfipGD7OPrfainxWWFTiI236jmHy5/0cr0uZNKHhN1OiMM5cAGzt3Wa/bo49i X-Received: by 2002:a05:6402:12d3:: with SMTP id k19mr38564394edx.52.1620769928644; Tue, 11 May 2021 14:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620769928; cv=none; d=google.com; s=arc-20160816; b=NvmrSXV2t9gHdQK0JXLlOwSlwO77CAHq6WZzs1a/M5C5hA/jvIlAoKaSE30878q20O kkaQ1Q3cCD5/XG5SiSUFsSp2P8rCuRrWDxFW3Emoe2mbVxrEJaA8KczW3/NmnKOITVS4 D2kBIyuYCW55m/orJzl1peoKfUJIloLD2+23c1R21osJJa5KKL1ONwHhiSkVjuhVZ+0T pejEAJnUMnaoYPFKSZwYPBVsjZ/CewYHPzR3Kz0d0XYFZI/bUz05MVzRWnNXZ4EXMF3U jeH/BEVl85887CMDeumpQN2WcNiJzIeHrLFJEY4k6usPHpkltfWJLb29Xyaa7WAITEt/ wxXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bbfLrrxrIOJ6efe5uzmRDhuhNNZGQcaXvsHalFUyJQk=; b=jl/VGf1zaF6lX0s29QwubnDzTqM5j/YIT9PIVNRUdYDHXphYechqCZZeWP+QDJlgY6 g3jpP3gkzZSIj7J7vImBQJe/KwM2Fvh9lbDkaDmF61v1XNpdS62hxq5oXutIjorElkVh nsKOBkczs+ic2NCuQfNPUiDFBJUHeK6A1u0rwPwaXyedj5jlxJZu1iikTM3bB/7yBn75 b49kcHIjjAv4u5elxy4aQKJkJ7ainruFMcrfyo876GBuAnr9WO9jIPi0kmUgbwtjAeKf vr1z7txLApQi+2CpLr4suS00dKZlQqke+DVHXG5p1huZL9qFO6x8xYIbIlz/Kn1Nacvu DhEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="o/bZ8bX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si23207178ejc.430.2021.05.11.14.51.44; Tue, 11 May 2021 14:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="o/bZ8bX8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbhEKVvn (ORCPT + 99 others); Tue, 11 May 2021 17:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbhEKVvm (ORCPT ); Tue, 11 May 2021 17:51:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0A26C06174A; Tue, 11 May 2021 14:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=bbfLrrxrIOJ6efe5uzmRDhuhNNZGQcaXvsHalFUyJQk=; b=o/bZ8bX8IbBkAfhSo2vijcj1xU /mUvXCskHac/k8yGa50RG5qC42m5MaGus7gqbOZls4jQ4M9AQp639YxADFa2GFF98lVsB5iGr0x7V Pg4tG2gP3VKqLdYl/xaDl0IK7efBikRq/WItgMAYe/YlYd4c0isjB4dP/6SNBEGlRFuw1Jx+xg5Ic qG/D525qLQxTR4h/QIno0teWOJYNX7tqgnTQlaeuSGwI5J5qYxo0DFWipYKvaEpBzCGR6eL8KOOCu vGN7C7yO8mQw8HgBP2+2znyo1LENk4PMaJHdeXclsELBbJ/vyZZjwPPAC1uNmPdxqfTN7IIzCOGcV gqfj+PAA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lgaG2-007hl8-Ik; Tue, 11 May 2021 21:49:43 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zi Yan , Christoph Hellwig , Jeff Layton Subject: [PATCH v10 04/33] mm/debug: Add VM_BUG_ON_FOLIO and VM_WARN_ON_ONCE_FOLIO Date: Tue, 11 May 2021 22:47:06 +0100 Message-Id: <20210511214735.1836149-5-willy@infradead.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210511214735.1836149-1-willy@infradead.org> References: <20210511214735.1836149-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These are the folio equivalents of VM_BUG_ON_PAGE and VM_WARN_ON_ONCE_PAGE. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Zi Yan Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton --- include/linux/mmdebug.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 1935d4c72d10..d7285f8148a3 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -22,6 +22,13 @@ void dump_mm(const struct mm_struct *mm); BUG(); \ } \ } while (0) +#define VM_BUG_ON_FOLIO(cond, folio) \ + do { \ + if (unlikely(cond)) { \ + dump_page(&folio->page, "VM_BUG_ON_FOLIO(" __stringify(cond)")");\ + BUG(); \ + } \ + } while (0) #define VM_BUG_ON_VMA(cond, vma) \ do { \ if (unlikely(cond)) { \ @@ -47,6 +54,17 @@ void dump_mm(const struct mm_struct *mm); } \ unlikely(__ret_warn_once); \ }) +#define VM_WARN_ON_ONCE_FOLIO(cond, folio) ({ \ + static bool __section(".data.once") __warned; \ + int __ret_warn_once = !!(cond); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + dump_page(&folio->page, "VM_WARN_ON_ONCE_FOLIO(" __stringify(cond)")");\ + __warned = true; \ + WARN_ON(1); \ + } \ + unlikely(__ret_warn_once); \ +}) #define VM_WARN_ON(cond) (void)WARN_ON(cond) #define VM_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond) @@ -55,11 +73,13 @@ void dump_mm(const struct mm_struct *mm); #else #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond) +#define VM_BUG_ON_FOLIO(cond, folio) VM_BUG_ON(cond) #define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond) #define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond) #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond) #define VM_WARN_ON_ONCE_PAGE(cond, page) BUILD_BUG_ON_INVALID(cond) +#define VM_WARN_ON_ONCE_FOLIO(cond, folio) BUILD_BUG_ON_INVALID(cond) #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond) #endif -- 2.30.2