From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750905AbdAUHHs (ORCPT ); Sat, 21 Jan 2017 02:07:48 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34642 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbdAUHHp (ORCPT ); Sat, 21 Jan 2017 02:07:45 -0500 Date: Sat, 21 Jan 2017 08:07:01 +0100 From: Ingo Molnar To: Jason Baron Cc: peterz@infradead.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH v2] jump_label: reduce the size of struct static_key Message-ID: <20170121070701.GA29184@gmail.com> References: <1483555303-13493-1-git-send-email-jbaron@akamai.com> <20170120071914.GA17003@gmail.com> <3a319fba-f655-1025-5663-16d9d185e12f@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3a319fba-f655-1025-5663-16d9d185e12f@akamai.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Jason Baron wrote: > >For example the last line could sure be written as: > > > > key->entries = jlm->entries; > > key->type |= static_key_type(key); > > > >right? > > Hi, > > So that is going to over-write the static_key_type(key) in the first > assignment. If the order is reversed we can't just |= in the pointer type. Indeed, I missed that. > How about: > > static void jump_key_set_entries(struct static_key *key, struct jump_entry *entries) > { > unsigned long type; > > type = static_key_type(key); > key->entries = entries; > key->type |= type; > } > > and then we can also add: > > void jump_key_set_mod(struct static_key *key, struct static_key_mod *mod) > > doing basically the same thing. That will avoid the casts that you called > out. > > better? Yeah - and it should generate the exact same code, right? I'd also add a short comment to the helper function that points out the union/aliasing, in case anyone is wondering. Thanks, Ingo