From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751374AbdAREfl (ORCPT ); Tue, 17 Jan 2017 23:35:41 -0500 Received: from imap.thunk.org ([74.207.234.97]:55850 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbdAREfj (ORCPT ); Tue, 17 Jan 2017 23:35:39 -0500 Date: Tue, 17 Jan 2017 23:35:36 -0500 From: "Theodore Ts'o" To: Stephan =?iso-8859-1?Q?M=FCller?= Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH 4/8] random: remove unused branch in hot code path Message-ID: <20170118043536.aeqmxfthmx4h33g7@thunk.org> Mail-Followup-To: Theodore Ts'o , Stephan =?iso-8859-1?Q?M=FCller?= , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org References: <3254875.f5A5oHPdxF@positron.chronox.de> <3380804.uZWydldqLU@positron.chronox.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3380804.uZWydldqLU@positron.chronox.de> User-Agent: NeoMutt/20161126 (1.7.1) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 27, 2016 at 11:40:23PM +0100, Stephan Müller wrote: > The variable ip is defined to be a __u64 which is always 8 bytes on any > architecture. Thus, the check for sizeof(ip) > 4 will always be true. > > As the check happens in a hot code path, remove the branch. The fact that it's a hot code path means the compiler will optimize it out, so the fact that it's on the hot code path is irrelevant. The main issue is that on platforms with a 32-bit IP's, ip >> 32 will always be zero. It might be that we can just do this via #if BITS_PER_LONG == 32 ... #else ... #endif I'm not sure that works for all platforms, though. More research is needed... - Ted