From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933644AbdIYB11 (ORCPT ); Sun, 24 Sep 2017 21:27:27 -0400 Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:4368 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933561AbdIYBOY (ORCPT ); Sun, 24 Sep 2017 21:14:24 -0400 From: "Levin, Alexander (Sasha Levin)" Cc: Jeremy Kerr , Thomas Gleixner , "Levin, Alexander (Sasha Levin)" X-Host: ranger.odc.vzwcorp.com To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH review for 4.9 49/50] genirq: Clarify logic calculating bogus irqreturn_t values Thread-Topic: [PATCH review for 4.9 49/50] genirq: Clarify logic calculating bogus irqreturn_t values Thread-Index: AQHTNZtty2uTtroEGU+4ByR/47NI5w== Date: Mon, 25 Sep 2017 01:12:59 +0000 Message-ID: <20170925011225.10029-49-alexander.levin@verizon.com> References: <20170925011225.10029-1-alexander.levin@verizon.com> In-Reply-To: <20170925011225.10029-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8P1SBUi015294 From: Jeremy Kerr [ Upstream commit 5d4bac9a5f4ef24b2482529bda6661a58e5b5b65 ] Although irqreturn_t is an enum, we treat it (and its enumeration constants) as a bitmask. However, bad_action_ret() uses a less-than operator to determine whether an irqreturn_t falls within allowable bit values, which means we need to know the signededness of an enum type to read the logic, which is implementation-dependent. This change explicitly uses an unsigned type for the comparison. We do this instead of changing to a bitwise test, as the latter compiles to increased instructions in this hot path. It looks like we get the correct behaviour currently (bad_action_ret(-1) returns 1), so this is purely a readability fix. Signed-off-by: Jeremy Kerr Link: http://lkml.kernel.org/r/1487219049-4061-1-git-send-email-jk@ozlabs.org Signed-off-by: Thomas Gleixner Signed-off-by: Sasha Levin --- kernel/irq/spurious.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index 5707f97a3e6a..061ba7eed4ed 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c @@ -175,7 +175,9 @@ out: static inline int bad_action_ret(irqreturn_t action_ret) { - if (likely(action_ret <= (IRQ_HANDLED | IRQ_WAKE_THREAD))) + unsigned int r = action_ret; + + if (likely(r <= (IRQ_HANDLED | IRQ_WAKE_THREAD))) return 0; return 1; } -- 2.11.0