From patchwork Fri Jul 9 13:18:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 471818 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp291725jao; Fri, 9 Jul 2021 06:18:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5iyGtwDwOumFwn9cKIwnVPa4fcdxAT7cM2M7T6HGs+9ne4I0ikWWRmvD2Ak+Y7w78TiLX X-Received: by 2002:a05:6602:134f:: with SMTP id i15mr28796990iov.143.1625836729681; Fri, 09 Jul 2021 06:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625836729; cv=none; d=google.com; s=arc-20160816; b=UabsiEeOXHgEact9lvMyn7IQMHso4Kc5xL1y2KlmAjcs1dClZ2cdD1m1iX8zJoekYr S1hXLG3n6S8eHPnZdgoirXppzP2u2jFv+rtoWShfkMylKCJv8+owsyE8xVcnMjZljoVW wrtEaEBkmpztyDUJYkA0eL3gQLpRkGGIsPLAUbNmL/bVvGiqc3M8Ap8gSxrjnlhoekJQ mPat5zJBoq6EyciJFRTRFXAyXBZtem1XRx9weuqLyKcHxBsA99RCXy2mDk8Y8op09qxR 9O7C7mcwGe8iQoSw8WsSG7hbLtp5I7Myw1qI1yelQSw/Qp46VQRrqrhsol2NfjFTVpPh kTwg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i8O+yia/vKWDwgNeF62Zp+m+kHt8q6PtntnJmKkPEC8=; b=ibBtehyTb9qIUgS9tR4KQzstF1hSDa+c8Svb0QPLwknF0t6aWKwCFLp1d92DtjcKWu zPThiBe/aayUi1RUwLv+54EXYbKs67o4is5KzHqXd4hX0BpZUTdfERk7ov9RZjKzpAkD kT9Q74VBtlN3aC4hv0GSXjHPlEzpmFM/XAwf75PGL7/vV34YKj+QyD96uL5svHD3RJmN aeOMta+/JNLbo7Cm+nBw7AyY4T/5wyc5vl2pksvo2WMb6U/WcqMENTI0VBib7BnJw8rQ TJ4CFom8ybIp4i0Oi+ZFjQpVBAVWWB8JjOM/RQQj2PHKSXSCnuaJzCT2WRFBlnw5kCeq vo5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mf/HRz7Z"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si6354360ilu.160.2021.07.09.06.18.49; Fri, 09 Jul 2021 06:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b="mf/HRz7Z"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231753AbhGINVb (ORCPT + 12 others); Fri, 9 Jul 2021 09:21:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:51616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231917AbhGINVa (ORCPT ); Fri, 9 Jul 2021 09:21:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBF0E61357; Fri, 9 Jul 2021 13:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836727; bh=PMRTvEShQzEn2+bkr+fk5C8BpeD20RIjfulk2Dc2K9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mf/HRz7Z9+fhwV81c7umMpr5UdrhCxe26GNL4oSluWsmOvC95GflZOU9/bPOUeaeV l7jye7BFRHMpt/Tud3LBTYZO1BdY7vFHaV8PeG2AE0zuwLnXUNxFcb2S6+BKOklrMS 0ydmvWSbTnLqmr/Z4oHipBrPdI5ruuib1o8K336Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Shi , Michal Hocko , Hugh Dickins , Johannes Weiner , Vladimir Davydov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 2/9] mm: add VM_WARN_ON_ONCE_PAGE() macro Date: Fri, 9 Jul 2021 15:18:29 +0200 Message-Id: <20210709131545.988367954@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131542.410636747@linuxfoundation.org> References: <20210709131542.410636747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Shi [ Upstream commit a4055888629bc0467d12d912cd7c90acdf3d9b12 part ] Add VM_WARN_ON_ONCE_PAGE() macro. Link: https://lkml.kernel.org/r/1604283436-18880-3-git-send-email-alex.shi@linux.alibaba.com Signed-off-by: Alex Shi Acked-by: Michal Hocko Acked-by: Hugh Dickins Acked-by: Johannes Weiner Cc: Vladimir Davydov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Note on stable backport: original commit was titled mm/memcg: warning on !memcg after readahead page charged which included uses of this macro in mm/memcontrol.c: here omitted. Signed-off-by: Hugh Dickins Signed-off-by: Sasha Levin --- include/linux/mmdebug.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.30.2 diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index deaba1cc3cfc..d1fb3bbff37a 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -36,6 +36,18 @@ void dump_mm(const struct mm_struct *mm); BUG(); \ } \ } while (0) +#define VM_WARN_ON_ONCE_PAGE(cond, page) ({ \ + static bool __section(".data.once") __warned; \ + int __ret_warn_once = !!(cond); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + dump_page(page, "VM_WARN_ON_ONCE_PAGE(" __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) #define VM_WARN_ONCE(cond, format...) (void)WARN_ONCE(cond, format) @@ -47,6 +59,7 @@ void dump_mm(const struct mm_struct *mm); #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_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond) #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond) #endif