From patchwork Fri Feb 9 03:10:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Goel X-Patchwork-Id: 127749 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp209262ljc; Thu, 8 Feb 2018 19:13:30 -0800 (PST) X-Google-Smtp-Source: AH8x225VHM7VAqjbwmGlEkGu+cMMCPV7N4NwM32lm36z9ek/YqM0z/ukN5ELJNDHbQRnUFu7xd5I X-Received: by 10.107.205.196 with SMTP id d187mr1450619iog.42.1518146010061; Thu, 08 Feb 2018 19:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518146010; cv=none; d=google.com; s=arc-20160816; b=coOq6j19SMmunD78ejNswjJfbmB/uwyNgOEZ8k+YgLmXXSTw6TrcKTsMidCpSlvvXc ppB8rS2azaI3gr3Daivt5vBFg+5FV3XrVglN+dJqDhDwi9ttr2qtJZZr3bV//qZ/ulzI Nbco460dNtMnGOPTK1AvpWWVvgW2LHcXA0evdnDG+tHVp37+MTPzwJDyqDrZFKSpfsTv Zbr7vTlmXNlqg7hCdfxLgtmHJYQ+BK9rtqNV14OpsyClCBBXCASsitsr71f0Bj5DrNvP 1E/CkkWbLPDozbIg/la4o3SexHmH2L2FsWbWEQtZyR4fbGvLZZ0E7yiOdiemYKVO+8MM M24Q== 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=tBAbB8AWZMLHGiwyw6StenR3zg8X77XYTnFIX9T/LKE=; b=q9c6S6Dhiqg4LS/1XzFKE+OGOXJBuy1rL9qD1XWgtbnjq2E6bDG3EkDFBWoJqSHoyB JmCSRqx9aE3LZuwb5i/flH5DfnOYEu9PFct7FBM9KG9W3hhtR7CGixwzNEe9SkimsFBg 7k5Uklm3kmiPdchfevpiFzD45nq34ze3qnPjLpOV5uqdjp+ASLCdgJr26w2H68ga222e mfrarWHRK6L5LpNTDETzlj/BVl6vs6wTdj0bUJk+rUy7GDGqqatWFDtypZPAAWOcgyu4 a8eJ9poqwOJI7N0DkfXNVWOHRlJWmfmViBJqd03P9PB2Anc3qOEAln3BmJttOD1CMVyV DomA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AKg52fbk; 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 141si973948iti.157.2018.02.08.19.13.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 19:13:30 -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=AKg52fbk; 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 1ejz5n-0004yD-Pp; Fri, 09 Feb 2018 03:11:15 +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 1ejz5m-0004y3-IQ for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 03:11:14 +0000 X-Inumbo-ID: d1f3e060-0d46-11e8-ba59-bc764e045a96 Received: from mail-pg0-x244.google.com (unknown [2607:f8b0:400e:c05::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d1f3e060-0d46-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 04:10:45 +0100 (CET) Received: by mail-pg0-x244.google.com with SMTP id j9so1668457pgv.3 for ; Thu, 08 Feb 2018 19:11:13 -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=lrlkNgB7UhGf2hvs5vkeu8ag00p7kkWbhs3n9tRKYJs=; b=AKg52fbkdD8/EmC9rION2dNU9SNwX3pWG0lqF+C/Mzr1fKHKXwGnsgGw2DCdtqy0nc g0DiVhBwtJONzNzE1RIbtJlbkFaqi1//+1voYJuF+HRzroPg/X2BMwzGocr3TL/5T0Lh EIjIlccWpQHjt6F7kyGw8WHG42xGXl0ID/enk= 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=lrlkNgB7UhGf2hvs5vkeu8ag00p7kkWbhs3n9tRKYJs=; b=EENN2Wkl0vqzPpr0M4tqeOobTGBB0TqH3KuSY7NpY6gCFfCR2sIjoB2dL7wr+Pqwe0 +ijUMjUmW6R0siOGPHPhCTLMvbQOcwpwvXeaZVaB4o+2PujLWBMT74C0JiqHy5/IT3L+ S+Mh5V7z10oskeUdU/u8vpdvT5ulMfzq4O6s+dbPI4FebgA9mD16N3+O+vAK3v/YId3A l/94VpGJtM1tRr+ZoYf8AjWTp11m/sCbE7xRV4mZWVNGzMyDIs+G9zFOCAbhz3r01LfU bBjXlZMFET/eBs1uwF/EIdL2ixBOMGgMzRBwKC+pMH4gk5AWQ2bcy+O7Otsacqij19WQ 8hUQ== X-Gm-Message-State: APf1xPBDF6O7EFCaPiqEHo3DZ6ljhCoP6h2YT2VT3QDodwL5CKnVyt08 GteUOYo69+VCRfUkPNs6WVvxoT4shtfe+g== X-Received: by 10.98.103.83 with SMTP id b80mr1296352pfc.12.1518145872621; Thu, 08 Feb 2018 19:11:12 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id z15sm2663487pgr.62.2018.02.08.19.11.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 19:11:12 -0800 (PST) From: Sameer Goel To: xen-devel@lists.xenproject.org, julien.grall@arm.com, mjaggi@caviumnetworks.com Date: Thu, 8 Feb 2018 20:10:49 -0700 Message-Id: <20180209031055.21926-2-sameer.goel@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180209031055.21926-1-sameer.goel@linaro.org> References: <20180209031055.21926-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, jbeulich@suse.com, Sameer Goel , Ian.Jackson@citrix.com, nd@arm.com, shankerd@codeaurora.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH 1/7] 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/arch/arm/xen.lds.S | 1 + xen/arch/x86/xen.lds.S | 1 + xen/include/xen/lib.h | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index b0390180b4..4dc7997cf0 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -87,6 +87,7 @@ SECTIONS __end_schedulers_array = .; *(.data.rel) *(.data.rel.*) + *(.data.unlikely) CONSTRUCTORS } :text diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 095298048f..353ca148ca 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -240,6 +240,7 @@ SECTIONS *(.data) *(.data.rel) *(.data.rel.*) + *(.data.unlikely) CONSTRUCTORS } :text diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 1d9771340c..697212a061 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -11,6 +11,19 @@ #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(); \ + } \ + 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 ")"); })