From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF6F014198B; Wed, 14 Feb 2024 23:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954757; cv=none; b=gBFdz7X34TvYIn984oNkKQgdchNQTviHKKKZ9eRnPvEtmuQwXdgbAPvUIv8f7lJwYYpzXTyyAe1AOvg5Ttk2RY5lNgGDL/PjQ/GaBjG6e7nDifUj+x4kstPs3GinY5LXYyR0AMC8Pwrzviz6FLSUGObQguhoIPXzK0M88AnO2pY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954757; c=relaxed/simple; bh=se9iJglQFcY5m50dOQjnyAPWzoyiPZ756eq3L6hkD1U=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KnNSw84g8CFHA0cdAWeUmcD33fzAWtu2LPtypmuceXnX8ZYWVWK0FgklrybneGbrqbUfsqU+R2lMNmgEwDgB/EtqjILDDB7hGJfsf2xFycEiFMeOWZAUjt69uYTvcFYq6nSD2cGhUK40AeObHNq8vPXSjyr50MfObtxgv/lkGEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F3A0C433C7; Wed, 14 Feb 2024 23:52:35 +0000 (UTC) Date: Wed, 14 Feb 2024 18:54:07 -0500 From: Steven Rostedt To: "Masami Hiramatsu (Google)" Cc: Alexei Starovoitov , Florent Revest , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: Re: [PATCH v7 19/36] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data() Message-ID: <20240214185407.767243b4@gandalf.local.home> In-Reply-To: <20240215084552.b72d6d22ce1b93bb8e04b70a@kernel.org> References: <170723204881.502590.11906735097521170661.stgit@devnote2> <170723226123.502590.4924916690354403889.stgit@devnote2> <20240214135958.23ed55e1@gandalf.local.home> <20240215084552.b72d6d22ce1b93bb8e04b70a@kernel.org> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 15 Feb 2024 08:45:52 +0900 Masami Hiramatsu (Google) wrote: > > Hmm, the above is a fast path. I wonder if we should add a patch to make that into: > > > > if (unlikely(size_bytes & (sizeof(long) - 1))) > > data_size = DIV_ROUND_UP(size_bytes, sizeof(long)); > > else > > data_size = size_bytes >> (sizeof(long) == 4 ? 2 : 3); > > > > to keep from doing the division. > > OK, I thought DIV_ROUND_UP was not much cost. Since sizeof(long) is > fixed 4 or 8, so > > data_size = (size_bytes + sizeof(long) - 1) >> BITS_PER_LONG; > > will this work? No, because BITS_PER_LONG is 32 or 64 ;-) But this should; data_size = (size_bytes + sizeof(long) - 1) >> (sizeof(long) == 4 ? 2 : 3); As sizeof(long) is a constant, that conditional expression will be hard coded into either 2 or 3 by the compiler. -- Steve