Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1723978pxb; Thu, 4 Mar 2021 20:20:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRf1OFkTCdFexteXt4CkOVJL0NIg/9CZEsaDUkMmdWBvbsQiHZ1yqHeX8OXtyRTKgzjVfl X-Received: by 2002:a05:6602:2110:: with SMTP id x16mr6814304iox.16.1614918014126; Thu, 04 Mar 2021 20:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614918014; cv=none; d=google.com; s=arc-20160816; b=JJLIFBRJ1UJTrbhObncyuonhq2yKVb9NriLLM8jm8zv9lfjXqoftTaMKesLORhfAyf ZVq1u2GghYDrmYD8REW0NSAm779V1gVyPmQkbQvACRZ5mxZWTdqF17Rw81z5RoThkaAI /8kaMRvj1e8eL60AEFg6ZTG/zv0hdCJa2DYRW02Z/olnbDQNR5us+yKmXIyntDnPmIvh lPW+gNYO4qPZN0cduTNBJEBXXumyXiLjU4AhBtgEG5fVjXB4XSFp0e9grMMDNyOl1hcf oo6L87MA72h2N+iXuGb+XxfRsTCAo5SN5y3a5KqDMHTross1F8HRCvExxz21yMW0M0jf F2CQ== 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=7x6Ty5MYTpzZNiotwF3DtVw5Sni26V7oFSAW6dNR/BU=; b=TPYu2QN4PGZJztU8f/nYmsQdMKEaaf1gHIoalNDgSvv8zfCS+9+pZbOR2zCIMaMlLt EUWin2U/0jRyRAE2pQ+VyU1VE4gxOC5E21TpoYt6/mDxyaTJBGze45DQBVGNL0OeRIqz OpPXdp8zPVCv+Z8zN7gv5SGYROs234cGGBTDs6umZSxkMeKkSi48RYbeHzCVPfHrvu4X kFDCostoPOOB4s8yWbEJLaNmtvE+GAROv7iP13q26Zoc9Xw1Sev2S5s2pSW6FQHKFrmM 2Pb2AsfewIBuL8nb/bElTmMtADbX3ijwHsDCPzu6NXQiBEx5XRfEbFFBJd1YFrTuIM6L KWsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Wb1jSPKP; 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 y13si1213360ill.12.2021.03.04.20.20.01; Thu, 04 Mar 2021 20:20:14 -0800 (PST) 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=Wb1jSPKP; 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 S229773AbhCEET0 (ORCPT + 99 others); Thu, 4 Mar 2021 23:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbhCEETZ (ORCPT ); Thu, 4 Mar 2021 23:19:25 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75476C061574; Thu, 4 Mar 2021 20:19:25 -0800 (PST) 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=7x6Ty5MYTpzZNiotwF3DtVw5Sni26V7oFSAW6dNR/BU=; b=Wb1jSPKPO3K3fViSoGnK2DgV5d Ax0oAKOCehujoZ4ZEATVJC28w0SEsEwINRYnpBUoXisBj3XrGOwSa8B8E+AwRCenM+i6KMNVJArif KOqWKiiDrk143vmc9gb1d2KaNTH2neA9x2uIjUN8bqte7g8NzK2ejMa0f/4QUJuTAwPWe21BzjIWS GUCtLphocGVnHQ3ZvP1QG2V1IbvpqYWVbo9ixux5y9i1MqlGwU+C8FPOTvCmTz5DKjp0MeFw89ufn p5ilyvYhRJ3IyGz+hZWdVzf0p7stsd+XLWPGZCzyIVAU6ZGOmwub0pa8SF9/2ofgQNWh2JQYajK71 Ll28toNg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lI1vm-00A3Sl-Co; Fri, 05 Mar 2021 04:19:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Zi Yan Subject: [PATCH v4 04/25] mm/debug: Add VM_BUG_ON_FOLIO and VM_WARN_ON_ONCE_FOLIO Date: Fri, 5 Mar 2021 04:18:40 +0000 Message-Id: <20210305041901.2396498-5-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210305041901.2396498-1-willy@infradead.org> References: <20210305041901.2396498-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.0