From patchwork Thu May 24 00:46:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameer Goel X-Patchwork-Id: 136693 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1557387lji; Wed, 23 May 2018 17:49:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplhaggvRFbeUi+KEozl2d0+I+Y6EB/N9e1v8pKATYtmjXHNmrGU4+7RvfO/sZJi6+kwMDl X-Received: by 2002:a24:6d86:: with SMTP id m128-v6mr7724018itc.75.1527122942386; Wed, 23 May 2018 17:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527122942; cv=none; d=google.com; s=arc-20160816; b=fMno8UuvgFKCw57AihWYctcM/PPMZdk1NuOFoxR0SJl945vr/aue1IlnV+W51jgp8C 4ZaN0Jj/C6XalWAgUoy7XZaIQw7+ISEOYCl2kBcuj1z4WypylOneBQktJ73i38Gd9Ikr CNSEIb5kBDrAu3DMu3n1uSWnwvozyHKOV9aI3Ims5p3a1i/X0z/0vLdU2c96aA+2FYeb WPbB9/YbwjFzP9j2pJimkWCOJgSgTCXB4Zc4zGmxjocSxRG5J9z6qJl01U5qlCvjWwVu YakWcO5f/CoWxuSlL0izL4PJ1flqSR3Ye2txhTbEJwAStmQgPix9eJF3qTHitsaKjwM8 IfZQ== 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=wnDt9HaZuu8HWQTL9+8uDsk9eqy9LYPOhOhNd6lBT4A=; b=VII9yvc6YCVlDHfQ/3g/c6VfJzp9SnmpyzlgtD4R3G75YM+4paayQDlcw/NAAsU/Jb aWPRXBD8S+E32imobUob/F63AxyC3BS9zo3HoreODYH3H6Ofj7teWkHk92k8HHE+dZRq r8+i+PiSi3TvDoZp8Yn9Oe1IfVagLXPdj+nJQuybqwA0k+8IKdOQkrVCS0DT59hUQ5qO L+YJSX7ioetnyBsgcDLYcy+OAEwqLC741dSl7SZUVyrQu1ivplxaj1CWOKUkkpUnXJhW BwHWVNDxN1Kily6O8V/YZtCKaBIZVNelurRQ5oDkZu5OWa9y3SUhUcN8TU49/BQEGRW9 MH9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TIU9y6ji; 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 b64-v6si3222991ite.130.2018.05.23.17.49.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 17:49:02 -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=TIU9y6ji; 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 1fLeOp-0001Bf-UO; Thu, 24 May 2018 00:46:35 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1fLeOp-0001BU-4d for xen-devel@lists.xenproject.org; Thu, 24 May 2018 00:46:35 +0000 X-Inumbo-ID: a3b9d2b3-5eeb-11e8-9728-bc764e045a96 Received: from mail-pl0-x242.google.com (unknown [2607:f8b0:400e:c01::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id a3b9d2b3-5eeb-11e8-9728-bc764e045a96; Thu, 24 May 2018 02:44:39 +0200 (CEST) Received: by mail-pl0-x242.google.com with SMTP id m24-v6so2655203pls.11 for ; Wed, 23 May 2018 17:46:34 -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=9XoGnaYThGmDbB/bOPWr0uKBQeBZSX0000nH8rdy44Q=; b=TIU9y6jipGSMyjlIxoVpASAFoX/OiRyhO6+WypsULnpgbQ0/OtvalKi3WbM7beJ9kV kHY2aIlqf4NorotZa+/apkWJByiRCfvgtLFAw9XHk2gTEy7A4rU2oFhx+oq/AbtaCTsP ybIqNVBSsr0EbrmY7Pp9LfWbNmX7FZQ+LWRfw= 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=9XoGnaYThGmDbB/bOPWr0uKBQeBZSX0000nH8rdy44Q=; b=nFoGdmFp9V/W8N6yApy7FblgaxFiuAtr2KhKtMwAz6G2WdT3b63QXTya9S7rjqAeF4 GgkzEhGW0cbpRSvv94hJHcAu9HKtpqK/gwi1lgpMjg/USQpJHuXoWdBhWOVQ6++RlaTF cwZaoIBFZq+Kds0MW7aFg9rzn5B/ExLCTPyd5auk1brnw9buIKoLWGwEddvhoIiUw6tf ZEUoogY8/hBxlB5VQJwfP+PW5vOO1mjlprr541UdJnZaKL/CPmKEIkLxfaEFMlLtZyTA sDaSxYAIiTrzJjzgW+rc93DY9JsETfE0nF0zy5WqNaY7MRM1aCp0+QIuT4H6xJ/gEOY2 qYtw== X-Gm-Message-State: ALKqPwcrb/hK5bxYTzVxou9Xt8A5DKaXCyl4ma3Cp9BP81X82JRvGZA+ G25rRSjTbBBjzmDMOcNxCKV/iGjZWWLwMg== X-Received: by 2002:a17:902:b490:: with SMTP id y16-v6mr5016549plr.92.1527122793507; Wed, 23 May 2018 17:46:33 -0700 (PDT) Received: from sameer-ubuntu-book.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id q15-v6sm18428438pgc.33.2018.05.23.17.46.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 17:46:32 -0700 (PDT) From: Sameer Goel To: xen-devel@lists.xenproject.org, julien.grall@arm.com, mjaggi@caviumnetworks.com Date: Wed, 23 May 2018 18:46:15 -0600 Message-Id: <20180524004620.23828-2-sameer.goel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524004620.23828-1-sameer.goel@linaro.org> References: <20180524004620.23828-1-sameer.goel@linaro.org> MIME-Version: 1.0 Subject: [Xen-devel] [v2 1/6] Port WARN_ON_ONCE() from Linux 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" 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 245a0e0e85..2f211be22f 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.unlikely) CONSTRUCTORS } :text diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 70afedd31d..11b2a93eb1 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.unlikely) CONSTRUCTORS } :text diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 1d9771340c..b8442a292e 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; \ + 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 ")"); })