From patchwork Fri Jul 9 13:18:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 471819 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp292599jao; Fri, 9 Jul 2021 06:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6fKJ383YwSqF5EyybdmrZlZ1uB7hevEwYdt2V+fgYXioLLyYXepa9JvfJNXHM8la32GDC X-Received: by 2002:a92:b003:: with SMTP id x3mr26690933ilh.93.1625836778306; Fri, 09 Jul 2021 06:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625836778; cv=none; d=google.com; s=arc-20160816; b=ZEn7fLKGyZJG90IRCasDNppKSbbchqcbszfo4IkOCMuF4TjeX/eIeY4m4uK0c73hKJ NvH7pNzPnM3d6VGBI0oFGMnHJPFel/v2u+PuZffhg4oKfuy4mSEnmfdZ08UjV+SwgUVe 6XRLF0wqGnMMXrJHQE1mWJrBTYk5pLtKdaGINlwi5BvnEdMYFYOsqpWMoJzFUljWzGs0 OZufMisDIRlGR6M3CJfFBNSdSyaMrlys+Jqc+IgODFOu4NxZVDp4qEGotahzxPVd+lhw k1hfROPo3VBrT7DnIB6SDlcPTmxJZR6kM0RTPwz32hu4zaaLAYhSfCdl8TIBJzNuao5n dPQA== 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=BQPZm2aUVBQXtHW5/mmXQYAC07A6T6+26B66Zbu7k7o=; b=EFnKPET4WJtrhiNxbzDUPEJRO0wqLwI2bpXN9eV0nRnVxXlD9WUEGS4bh9EQ1EgbcU vl2llfZrui6dOAOtBJYXdvLUSD07RSr8pT9+kXnFEKqcJR9f2u9t89pt3VOnhynuZMeH DthTJ/EG+khvo3vQM0YaDFJPCIhzwxuI3EeQySevgTKEDMSxI1cB7fGNLdKFK1ZTl6a0 t/ghbRtpluhcEHAEJKBWe6t93492AGTW2ojMQcPx3ltDlUD+/jf/wavfTllcwBDqpXTz mV49Jw71loGuVZnCZc52UCPjSsq78TfvhHQAsdNOw+7V1vubRIu0XJl5mR6suVuJe4l+ oejQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="F/TOh+zf"; 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 p18si5547450ios.10.2021.07.09.06.19.38; Fri, 09 Jul 2021 06:19:38 -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="F/TOh+zf"; 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 S232208AbhGINWU (ORCPT + 12 others); Fri, 9 Jul 2021 09:22:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232238AbhGINWQ (ORCPT ); Fri, 9 Jul 2021 09:22:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 346F76128A; Fri, 9 Jul 2021 13:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836772; bh=OsAW912EnxIIBeMknGEAHaC5qLWswKGKvuAOu/zl5gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/TOh+zf9z+LJZToCQzbzP/4RpmoA5De3TtvTlyRhbWa1xomPzXWZLur+6W5z7RnI F6THgshZoRKVgTE0nVGjqnnm8Z/XZzMSrRUKBWDW4pb5rL+lUpp/WXfj44c8qc8fFi /PGuvjLyL4yDOXFZRclbC+pKP792mdYU8Gg6z+F8= 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.14 02/25] mm: add VM_WARN_ON_ONCE_PAGE() macro Date: Fri, 9 Jul 2021 15:18:33 +0200 Message-Id: <20210709131629.344880174@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131627.928131764@linuxfoundation.org> References: <20210709131627.928131764@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 2ad72d2c8cc5..5d0767cb424a 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -37,6 +37,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) @@ -48,6 +60,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