From patchwork Thu Jun 7 23:47:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Goel X-Patchwork-Id: 137903 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp207213lji; Thu, 7 Jun 2018 16:50:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIt1FdanZT7pqtZIFCBIP8T012xTqJZUSpdB819OnDOwVvveYFPjmms5micmT7V3lJ80WLN X-Received: by 2002:a24:798f:: with SMTP id z137-v6mr3693703itc.19.1528415424885; Thu, 07 Jun 2018 16:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528415424; cv=none; d=google.com; s=arc-20160816; b=L0Ck1o5C82rRB11kYZ6p66ERXVtGBehesAjSJkdJMOgUDX5wRJI5oiyIRdCaGapw1c BFBjOk2lFfuoUTQXImWvvO8gL3J8oF0/2s1mmDxYvLosJ6OYbpYvkI+1Bem1mNI+xeLX 5LhtIXNFN/fvjkST0Z0qp7UR5e1qH8mr+iqHu6l3bvUbuKWSclC71O05hqks2A7abNiI dRHKsw4NOr62vAW0vmJ+9pgmX/blzvveBeCqG8Y8JDY8wYHkOXBXTaJk689JDfEbAZJV AZ2wkMkIbTfWnheX9Zk3TFgNelzi0FSnWNkLNVz3rkhKeAocv+Ec8HEYr5CW05LDJIWL UUJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=42rVgVLH693oCX2IZvw3YGssL5simsAXNS6Kz2UBAus=; b=YwiWkjmnxvCFPMkEvKq09cVWldJSSt+TsgXTiueV6Nkdu+ZlJg04OZ4DlcUDPzmFxa wLaRan19VZbkNzPD6Q3dq35tZZuzpnyfFJpm1wsq88EDfdCJ3AJHWz/+MPzt4Nh3C84O 8gbVtgjHLmtRCme2ZwyqCbP3HF/CWLbQh5g2lWEmybznREafQ4Ez1K7dwNWtDTBao73H 3bsyZxGux08Ft5k7mdnY7ykIxg7Rx6N9N0pObn1JbiNHI5uIM1fWV6FifBRPlILhKWVP wAMGdWMkLI+6r74uTwvtQOL1H8ag3uUNlGcYTn4G9x+a81pjEJnTasU1rGgtTZAkuanI Bn9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ecq4QX97; 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 q65-v6si122545itg.6.2018.06.07.16.50.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 16:50:24 -0700 (PDT) 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=ecq4QX97; 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.89) (envelope-from ) id 1fR4dA-0007gQ-T9; Thu, 07 Jun 2018 23:47:48 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fR4dA-0007gD-7C for xen-devel@lists.xenproject.org; Thu, 07 Jun 2018 23:47:48 +0000 X-Inumbo-ID: db58945a-6aac-11e8-9728-bc764e045a96 Received: from mail-pg0-x241.google.com (unknown [2607:f8b0:400e:c05::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id db58945a-6aac-11e8-9728-bc764e045a96; Fri, 08 Jun 2018 01:45:28 +0200 (CEST) Received: by mail-pg0-x241.google.com with SMTP id l65-v6so5490546pgl.8 for ; Thu, 07 Jun 2018 16:47:46 -0700 (PDT) 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=64sF0jE/TiJILCG4LT4lF6Pwa9/xs4snoKvBkxoG11c=; b=ecq4QX97fIYDq2t7AhpzrlV/lcBW/KlxYb+cgHl1HbNFU/5+1oDMznOg/piCSe+qA1 HymxpKhMSUfbPxpBGl/1K/1KPzV65kbN05tZuQGgAaKxHyU56pBLr7bvZp2e+JB6lwoT jnNQzkX9cB+wyCDnPCQ7Rzz4wy/KYlVwZcPHw= 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=64sF0jE/TiJILCG4LT4lF6Pwa9/xs4snoKvBkxoG11c=; b=eO27krtpPrAWtVTJWHH9hPiTKkXqex9pp13ZThOMQvpqFJCeJ3YQoz76ZgvjN2Hv2S 1qQu6wsHpFOQBVeeD1+Go2VUH3JxP0eJ0fGtjAcAj29LPpigje/BSF06qive7QtxBkBs a0BAOrefEQXVMI7+6wOYOOVL4ug28NwNzfqfKSc4uNTOBRjNqIBjUoX1SnLejE3JlgyE cypQ3C1PSS94Ol06sYYYomMpPop6r6QVamiBsqTfkgOoQ3dH8+XM+zrfjDlxFUTlP9Bt 0x6BPhBiWJnbCPzLDCzBWnbR10YYLerACpjzdRuFCLY0XR2fYxGevKi17wMt1ALfpf5r P3Rg== X-Gm-Message-State: APt69E3LM2+4hEi/KZmGiVk38qtMVKOsiByGvLsOgPUZYOUk51uSakCH 8Ref1WQ4t4KwJ/v4myCNx8WSc2gNy09dig== X-Received: by 2002:a63:6fcb:: with SMTP id k194-v6mr3130672pgc.93.1528415265890; Thu, 07 Jun 2018 16:47:45 -0700 (PDT) Received: from sameer-ubuntu-book.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id y20-v6sm46183321pge.46.2018.06.07.16.47.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 16:47:45 -0700 (PDT) From: Sameer Goel To: xen-devel@lists.xenproject.org, julien.grall@arm.com, mjaggi@caviumnetworks.com Date: Thu, 7 Jun 2018 17:47:27 -0600 Message-Id: <20180607234732.20124-2-sameer.goel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180607234732.20124-1-sameer.goel@linaro.org> References: <20180607234732.20124-1-sameer.goel@linaro.org> MIME-Version: 1.0 Subject: [Xen-devel] [v3 1/6] Define WARN_ON_ONCE() macro to mirror Linux functionality X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Define WARN_ON_ONCE() macro to mirror Linux functionality. 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 245a0e0e85..1ef714110a 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -94,6 +94,7 @@ SECTIONS __end_schedulers_array = .; *(.data.rel) *(.data.rel.*) + *(.data.cold) CONSTRUCTORS } :text diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 70afedd31d..51d9da2482 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -270,6 +270,7 @@ SECTIONS *(.data) *(.data.rel) *(.data.rel.*) + *(.data.cold) CONSTRUCTORS } :text diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 1d9771340c..2bdaf6d60d 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.cold") warned; \ + bool 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 ")"); })