Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7466905imm; Thu, 28 Jun 2018 04:24:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe4UDpQJw8e7EFjKyZXMFU9eghrS+P9NjjwYJ/jk8OWDJ3Scpx+wyRgLKuwASjY19ZjrZS6 X-Received: by 2002:a63:c252:: with SMTP id l18-v6mr5449071pgg.76.1530185054871; Thu, 28 Jun 2018 04:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530185054; cv=none; d=google.com; s=arc-20160816; b=PeaJyTMIGhyF0a8Pj6+07nAValrq4YbjUBs2QKWDhmTMddQ6ZfifrW71EyutgNRwAL O+1dDqBIUWhPZ9mvVHvMpFhERbclDLAy8kRyuQKyzS9y2rj7g8MMgZCtTnKwMNpdxgrO qogAhzVPNfTURMgOG1qVpQp05+x7NQwFLwMR0GcjgXkyJSH+pjKSim4kASDTec9etFNP nXzYix4qIJst5ZcmVk5cNAQgYExi0RadO4GUGxQ8uorbEyJx+mEYhk09JNj84aWtwra3 mgz35s5Boho9Tmj0P42z+VxlvAs+C9ysVh83TIvKCqJCPlkkTvJWAIbgZUICYyFz8tAc 1neQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=VaYagYMjNLi5MbppvTx+jyrVgSqhqS5U8HypcAHit6E=; b=pM6jhdYi2h/NwonNbq8JHPDkU9yiA9Akwh7nlWwavLfmVn/Fyawd9iEU65vlzz8CHj SRlo5a5rWDXXvxkn9UgTShiXWgGPE8ByVcvueNapWb6/IfFNt/x4khxJwZoBF0SRa7bO 6rUjZ3+koQd6nOY5n515UpxHgzkoTeaI5sVAvQUVpcPwcNmKY3cu/UmInesP5sRnCylS WSaxnsV+lkB/6eXHlIiOa0EzgxSaUZUj/E9VJt5E3Pvk8VHTmfVakmyeoi40vWDh9grp ccSsrHheQJu0sXNsf2fZJXuacoFXZV2xZmMblk0wLQlEpIw9uZZLWEMCKah2lGRq64Ik mB5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=m53clXBP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2-v6si6193421pfl.133.2018.06.28.04.23.57; Thu, 28 Jun 2018 04:24:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=m53clXBP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752997AbeF1IuP (ORCPT + 99 others); Thu, 28 Jun 2018 04:50:15 -0400 Received: from merlin.infradead.org ([205.233.59.134]:52458 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbeF1IuN (ORCPT ); Thu, 28 Jun 2018 04:50:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VaYagYMjNLi5MbppvTx+jyrVgSqhqS5U8HypcAHit6E=; b=m53clXBP+KMWO6W8lVT/UIkoy JZeIZf8XmzffvFUwckJ18HnHV/lQ0Hq4LRZAUCldMJb1lWOgMQ6zOIkKMDzuURNSmYp6QNLwVYIo6 dLR5speD2kU0ebpCsagjYMDmzUg6YMDVKGjEXvy66mHGvtMJCzXTGotBuyPlN+XMlnLPOr4k0sxMc 8ikIFXq4vm9sZXtPAAYI0cHBQv5G0tH1k4pcfDlk1XYGCbhUirwN0emC3DHi3ZqDwRkyQH1mXhhC9 8g+/jOdvUGmqqxTmgei+yZfIoagOUtG4Ekd/dFe0bPru8xH4+3ONKBmICzPkOHth4GyR/italG9qj PkrnETh2g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYScv-0002gn-07; Thu, 28 Jun 2018 08:50:05 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8B5E320297645; Thu, 28 Jun 2018 10:50:03 +0200 (CEST) Date: Thu, 28 Jun 2018 10:50:03 +0200 From: Peter Zijlstra To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Arnd Bergmann , Steven Rostedt Subject: Re: [PATCH 2/5] kernel/jump_label: implement generic support for relative references Message-ID: <20180628085003.GA2494@hirez.programming.kicks-ass.net> References: <20180627160604.8154-1-ard.biesheuvel@linaro.org> <20180627160604.8154-3-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180627160604.8154-3-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 27, 2018 at 06:06:01PM +0200, Ard Biesheuvel wrote: > diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h > index 86ec0652d3b1..aa203dffe72c 100644 > --- a/include/linux/jump_label.h > +++ b/include/linux/jump_label.h > @@ -121,6 +121,32 @@ struct static_key { > #include > > #ifndef __ASSEMBLY__ > +#ifdef CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE > + > +struct jump_entry { > + int code; > + int target; > + int key; > +}; I much prefer you use 'u32' there. > +static void jump_label_swap(void *a, void *b, int size) > +{ > + long delta = (unsigned long)a - (unsigned long)b; > + struct jump_entry *jea = a; > + struct jump_entry *jeb = b; > + struct jump_entry tmp = *jea; > + > + jea->code = jeb->code - delta; > + jea->target = jeb->target - delta; > + jea->key = jeb->key - delta; > + > + jeb->code = tmp.code + delta; > + jeb->target = tmp.target + delta; > + jeb->key = tmp.key + delta; > +} > + > static void > jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop) > { > @@ -56,7 +72,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop) > > size = (((unsigned long)stop - (unsigned long)start) > / sizeof(struct jump_entry)); > - sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL); > + sort(start, size, sizeof(struct jump_entry), jump_label_cmp, > + IS_ENABLED(CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE) ? jump_label_swap > + : NULL); > } That will result in jump_label_swap being an unused symbol for some compile options. Would it not be much nicer to write that like: static void jump_label_swap(void *a, void *b, int size) { struct jump_entry *jea = a, *jeb = b; #ifdef CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE long delta = a - b; jea->code += delta; jea->target += delta; jea->key += delta; jeb->code -= delta; jeb->target -= delta; jeb->key -= delta; #else swap(*jea, *jeb); } And then unconditionally use jump_label_swap().