Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1579552pxf; Fri, 9 Apr 2021 11:57:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPJNrySCSML53PLCyLHyNoQvt17gXN+4NeqOydjWw0q9fpTIRBkpGLz2kC9qObSEaZ6STM X-Received: by 2002:a05:6402:350b:: with SMTP id b11mr18505876edd.288.1617994638008; Fri, 09 Apr 2021 11:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617994638; cv=none; d=google.com; s=arc-20160816; b=A5SkTJG0Ylct9nHzF0w0+n4MJspPEduEslf9h1SHx6v3tYewkq9CW+ezaqkKYzAqKg dd0s429O8pQb76/rAmHj0qHfoeXIkholbIho1ztB4RmBJMkLLIgoufYnye/FMUvAfDOV HgPqBuJ3txFKY/L+ngoVJyu7LmqMOJ1M1QghdFcuKG1N1s4ejgaHhLJv1jNQNp7MCkBq 5mcuSFasCAUGtkgjEMzgSPxbS96P6RGJcEsrKJrCiUD/d898IZ94gEc8fjCrU/Plk3l3 BInX1kmdf445yDOkvG7IbgrSEk4wYdlgAUasp7vAqyBDG78xKbnfAP0S8QLfCUl+1oB3 4GRw== 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=WgtJerUq2+EOZX8C2WOKla9RTZ8JhXvu2XoZvGKvg78=; b=i1wHae9gop0rBP+BgJvyXPcQ5m5MwT/djUL8ELA7Ea76UDqlUwck7UZAKSBFfdclIJ lOqiGHC5z6ARr9o4wXaYCM1pGhhFIY2Z2IIGA1NR2HbYie9LN1V1JXGkcvq+7xRHVqKj aU9E5BAP1YbyIt7MReN9InZRducOlCJwop8/2+2vxJASDTXLze2hwIN6HuMjS3v2y772 P+aqMMFOxRdG+Gsy9Hkbkx13czKZ9Z335doflvTX/PbuigAg3vH8DbjioLD2oQCSmNVT LrdqCKaGhxznZSPUQymO01oB3tyHnhsbnuywjCBpP7hWhZmPzewvUm0/os7CkizycNhD kozA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e3HQD3ms; 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 an16si2453460ejc.39.2021.04.09.11.56.54; Fri, 09 Apr 2021 11:57:17 -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=e3HQD3ms; 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 S234703AbhDIS4O (ORCPT + 99 others); Fri, 9 Apr 2021 14:56:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbhDIS4N (ORCPT ); Fri, 9 Apr 2021 14:56:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F6DEC061762; Fri, 9 Apr 2021 11:55:59 -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=WgtJerUq2+EOZX8C2WOKla9RTZ8JhXvu2XoZvGKvg78=; b=e3HQD3msEJHMxXsmkkrKNF4sXX KDhDNJJhOfUj+79VS1ymu8qo/BSfNF0bk9pFrJA1BZhoFqUgSpkHq+sh/v07XkgpXvzj22LOV7DYr cIH/LxpZh81SrLoHDjWRHN8PJROHJxeYjajTehd0CrTMiCXM7B/pIeCPUz2HAItrsHrQ8ofSQVK7f ksoBWLVyzSZBOTSWZ6Ef/Amt9uxshjJPtjayWZvg/o546B+zctA4yXHuCDsO3ObmgqC1F1kVIwrsX I0+LM6X8W9bcTonZeyGlq8qnPXhXqWNLwNuIrArJIqSGtrnyDsvAiCEH0XRUkH2B/0MdR7X+R8Ugb 151sqtBw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUwGp-000nDv-NO; Fri, 09 Apr 2021 18:54:37 +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 , Christoph Hellwig , Jeff Layton Subject: [PATCH v7 05/28] mm/debug: Add VM_BUG_ON_FOLIO and VM_WARN_ON_ONCE_FOLIO Date: Fri, 9 Apr 2021 19:50:42 +0100 Message-Id: <20210409185105.188284-6-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210409185105.188284-1-willy@infradead.org> References: <20210409185105.188284-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 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