From patchwork Tue Dec 19 03:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Goel X-Patchwork-Id: 122336 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3622100qgn; Mon, 18 Dec 2017 19:19:54 -0800 (PST) X-Google-Smtp-Source: ACJfBos87zIyGu6WQb2urlXRjqGxmKI4SLM2YcdoukYc86G5y5W46ixKDJX3AIJR8YwhkszOQ7kf X-Received: by 10.36.76.212 with SMTP id a203mr1542453itb.132.1513653593972; Mon, 18 Dec 2017 19:19:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513653593; cv=none; d=google.com; s=arc-20160816; b=PlQJy5uMXjJY6Rg0SWSZrQ9ZrHkiJKZUscV7txsZvAiOBeGqBhAMzjqOPA+cZ6NHGA PyuM9/GwbtR5HFa2eDNl+92M6HrceZnRmYq6wxkdyY4zN+tRYgBIw8Az5dw/J3UZkNdl YQYpMZ08UzIGw1yUkExbCgp4H8vABmqT8wLUr9zGMjp0q8hSikgUxYqtWnGveJAKg+zY 2691EkUjmPT9rTy9T1bHoo0RTkGV3T4Ihrkav2cJtNFzTerDGKotDJEWdaMKe0XMdTID N8jXPaXYhqLhMCineDREhhSTgyEe+cDqK6Q01mUOzNocZdwFIuCI6ou6BvCmuXr9ndTy WS5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-unsubscribe:list-id:precedence:subject:cc :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=uSGlvAmLsO2NQksaWVOEc1HtPvAY+UpY3K4CLMmsPd8=; b=NE76PtnWW2X5MoEah2jkLJEQ+bfUDe6u7l8NVHyL3oUqZjgQH6jAp917ZQukI2dNWy rmVh4W7g9QTNjBs5Uagw5zQxIC4IJMJfUDSnp89ZRWWVtdgC96M28qmZk1UhUfd0Kpjt AsMFiZ70pD8jddzF5OwtBjPRo6yukiapJPtxkhWKQwRojTJKZ+e/zCRvxdytrEZsKDKJ lR/qM2guLPZrIQ+KsC4Qj76cA3inVgnYQJgJSGJ+w5wBRUW1GSnT1B7/J0zMZewUEms/ 0DntsUKWUMufJtNqrM59LAf8ylnCoytmKdJn4SxO2CLpZHOQbq+OuuAKEwHA7lA+dhb0 unfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BYgZvWuF; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k24si11279082ioo.84.2017.12.18.19.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 19:19:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BYgZvWuF; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR8P4-0006aR-1o; Tue, 19 Dec 2017 03:17:14 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eR8P2-0006aG-UC for xen-devel@lists.xenproject.org; Tue, 19 Dec 2017 03:17:12 +0000 X-Inumbo-ID: 0118e616-e46b-11e7-b4a6-bc764e045a96 Received: from mail-pf0-x244.google.com (unknown [2607:f8b0:400e:c00::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0118e616-e46b-11e7-b4a6-bc764e045a96; Tue, 19 Dec 2017 04:16:29 +0100 (CET) Received: by mail-pf0-x244.google.com with SMTP id y89so10605546pfk.0 for ; Mon, 18 Dec 2017 19:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CIiPHqvTxqa7FAVP8pZCqNZ6AK7Ia0cXriOGNMe0ngQ=; b=BYgZvWuFT8BOqNtN06XdOp25pRF3BoDIl6oiin3ZMt45M/piHwmc8GW9IYPGP5BbQK r4Tl0EA4Ae8jwEj4vHRWFj5/QCWrjpHJnMfNBSHnlCXpP0TiZT133R+TFGVSfcPvYVLQ LzYHbPnwAM6z2PwI8jKfgNwZ48+3B5O3WrbMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CIiPHqvTxqa7FAVP8pZCqNZ6AK7Ia0cXriOGNMe0ngQ=; b=Raro6fDeb5b6LBBDFbalcRKXxIWnUDICQJ7cpTtiLsGsOh6x/2T1ylFVGZKrkk65ln 6ZJCBngd8njinY+ZNgqjR814qRv5ePEjEumV/TyMvJd+PeAby/jEwz2YfDY+O183d8Ly gqcJVVfcvJcd3OwXerIcsUY9zaVZwWTGdmd0U7W/E8xWd5mS3itfQu8C66U7Ottgi1H9 l6B+PChNemhu3MRhmTVWlVOd1RAS8O3N/ntb4QzDNYFHco+Spo+m8ljPy9OEPsScYKaV ZHUYh1TiPDcFrS0su0S/KkRi/37Dr0vin4cGBzkffTQ9TYok5UfHj8HTHAZezHJFi2Lg W5Uw== X-Gm-Message-State: AKGB3mI/mWYR9E/3YSeSUZSFUmOsXvAxo1ELteMH6ahCAhnasHy7MP0G H9x4hBQbDzkpL6VxcIMXERqh8JU937aAVw== X-Received: by 10.98.157.219 with SMTP id a88mr1785888pfk.126.1513653430772; Mon, 18 Dec 2017 19:17:10 -0800 (PST) Received: from sameer-ubuntu-book.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 84sm28289917pfp.180.2017.12.18.19.17.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 19:17:10 -0800 (PST) From: Sameer Goel To: xen-devel@lists.xenproject.org, julien.grall@arm.com, mjaggi@caviumnetworks.com Date: Mon, 18 Dec 2017 20:16:56 -0700 Message-Id: <20171219031703.23420-2-sameer.goel@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171219031703.23420-1-sameer.goel@linaro.org> References: <20171219031703.23420-1-sameer.goel@linaro.org> MIME-Version: 1.0 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, george.dunlap@eu.citrix.com, Andrew.Cooper3@citrix.com, andre.przywara@linaro.org, jbeulich@suse.com, Sameer Goel , Ian.Jackson@citrix.com, nd@arm.com, shankerd@codeaurora.org Subject: [Xen-devel] [RFC v4 1/8] Port WARN_ON_ONCE() from Linux X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Port WARN_ON_ONCE macro from Linux. Signed-off-by: Sameer Goel Acked-by: Julien Grall --- xen/include/xen/lib.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index ed00ae1379..83206c0848 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -11,6 +11,17 @@ #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) +#define WARN_ON_ONCE(p) ({ \ + static bool __section(".data.unlikely") __warned; \ + int __ret_warn_once = !!(p); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + __warned = true; \ + WARN_ON(1); \ + } \ + unlikely(__ret_warn_once); \ +}) + #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })