Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2075036pxf; Sat, 20 Mar 2021 03:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwggnKuEG0oDLkBrltakFstSWtGXu24YnyXgEw56QcdYuCikVCB3T5W2GBS6gQjxc4Rt6jW X-Received: by 2002:a17:906:1444:: with SMTP id q4mr9212775ejc.343.1616237587277; Sat, 20 Mar 2021 03:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616237587; cv=none; d=google.com; s=arc-20160816; b=aU17xbfdgh93odI4EGzwlaaAWgNIIOtgvGSbMTtwyMvokufY+S3wZERpzjUDC3Ih9V ketMRaPXsDi6oS6EdR96NbKcNNAb15Vqh+D1G0sLOj7XMNe85k32Ev/N2W48rJ8qF5Cg wX2UDwGA4/5c7EOZvxY2kUxU8TDGY+e+Cu3NWHeb5lVrY7msOvvnLWl6zOlpp0ssM0jB u+xa6aCrCjBqYxIkt7IC7gNcUW+BwA9DUKGWBEg6oStcfKEQEPlL0Cnl01rmGAmEmq9/ 0RTk76C3BEJ+2mjkdmlB9//s4S0gjlipzhHDSjuhBkvkrNrMuEm/JpEpjRDV5pCcrpTC aG3A== 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=V4CfUCmxoMh7fYAdXEYFgH1auhBTM+MLJMhUkFKBq20=; b=l46Fe6UX+31XLNdaCtQ0CLn72DVSqbplFBcUIn9j8DeN0zh1SHKujQU9pBqc2FEdgB K+JzMysZu/a/t/MfvpqXPYtPU9kvZo8bFHnspzyUT71M03srsJxMjNqDEsxgaEhCexK/ cSR7vEMVHHM3rTMiTWElXdswJTzg+hDO58GZYzoovcZdwLKkKirHQt46OybkklMrs5SC ko7ZmJv3kfX8i9FwdQcXHlALisety+owTcH8YkwyskzAdpjPGuop2h1kCRS8eOdAOnaf 6R/qjYkP3lkDzqhtnk2A9MMb5giMSgRRbrBb3PlQE1SA3MDCeP7jM6zBlKjFzpgUK5Yl fS4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KWXrTPlG; 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 u7si6446750edo.259.2021.03.20.03.52.01; Sat, 20 Mar 2021 03:53:07 -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=KWXrTPlG; 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 S229993AbhCTFmj (ORCPT + 99 others); Sat, 20 Mar 2021 01:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbhCTFmO (ORCPT ); Sat, 20 Mar 2021 01:42:14 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9368AC061762; Fri, 19 Mar 2021 22:42:14 -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=V4CfUCmxoMh7fYAdXEYFgH1auhBTM+MLJMhUkFKBq20=; b=KWXrTPlGkKg3f1yAjPgIhRxP1K Q+M6KXpRD+WhB0WDZcGujhcL75jS88qhRwVneYektuFn1aKBj7B/Xg6rynIJyqA4EXfo6URW+qEBW ed5YIbrhOx4wLH+5dL6A0RZxxHt36rWd6pkDrSgU2alGzYINXxavIoECwPesdPxityyBsOhJPThoL rQ33scUcrF4TeT3wCH2U2qALjpZAX8WsdeedAjVMQoYTOEnchsGQWIFfsCEPybRvBbdnjz+WVTzX2 29FOcQZ/R7eEhuirKDytslYBajp7jFyyrDnVjbd+YIzcOVc/5grAVUt+0EmOcz81RAMdpsqxeTjhx G1srbhHg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lNUN4-005SUw-H1; Sat, 20 Mar 2021 05:41:59 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, Zi Yan Subject: [PATCH v5 07/27] mm/debug: Add VM_BUG_ON_FOLIO and VM_WARN_ON_ONCE_FOLIO Date: Sat, 20 Mar 2021 05:40:44 +0000 Message-Id: <20210320054104.1300774-8-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210320054104.1300774-1-willy@infradead.org> References: <20210320054104.1300774-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 --- include/linux/mmdebug.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 5d0767cb424a..77d24e1dcaec 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -23,6 +23,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)) { \ @@ -48,6 +55,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) @@ -56,11 +74,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