Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3544243imm; Mon, 8 Oct 2018 05:54:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ckQSbovl1cr5maUFRhmBO6JqMnnTTUy/TjmsvDS3GJ+SA9cSlJn4w6+eTFULyaGJqGST+ X-Received: by 2002:a65:588e:: with SMTP id d14-v6mr20889928pgu.117.1539003249312; Mon, 08 Oct 2018 05:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539003249; cv=none; d=google.com; s=arc-20160816; b=m+C8OJJqrmIC99ZwFNuEI9p/OFVZ4pSchZQCs/q1z53X/GZ83oJI3DiuMwOQnfkjYa MIQ/Ij7oG6snmH1hugyqya8X4+l+2V/DrzuXgqhXRGNERTOuRLiSlsag+JILKIOCCzPS /UvyDJt1qfWPs+gUUf2PysTRoEI5hx/f581UYNXJu3VQtBdkT/HArQcWMTl5BuKI6P+a 2bDjgEJsWZSu/p35R7RV2dIOks8mJ1ZUAf1w/B0zz9sJUUJi05/wU5Xt+SVVO011AS5B 39JAVOtqrdbL2+7CjkHKgy2XEFIJuYBabwlZQfSgMYluHRVWSKY5WUbBjK+0NtQb4tNO dVZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nAuQhyynjlo6jwcO8Cz0NGPsohOKTCoK+qZ0vZShl1Q=; b=pKQiYBclaXZY7TqI2y2D+jIiG48gkPH5dG+4c9ksM5XYj1cIEnJZguWu7GbmK13IaJ sAjFpzULWie/vsitEMWrKvA7Bk5H1msDjGA1j5z8CMl0+fmi5vFEg+QB7mRqYbqu5CIh fXCS3Id18iicA/4Osz8NlU7c+yAx+ExsbtOgct7QHlwX8H0ZFOftDjixyjuRkdYEu6U7 vp7/JFcfL9YwYTxjPEJksbMdCxFt69EtGaYRBylwxAYumpku0I3v93x8pmsD21nX0050 SiKCK0oLZZ4p4FRhhmjqh9Vei1uRp646buHeQhLJmEbNyNZW9zhb3b62AQOjWKqQX9WZ aINQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9-v6si18814845pfg.46.2018.10.08.05.53.54; Mon, 08 Oct 2018 05:54:09 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbeJHUFE (ORCPT + 99 others); Mon, 8 Oct 2018 16:05:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35720 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbeJHUFE (ORCPT ); Mon, 8 Oct 2018 16:05:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A89EF308424D; Mon, 8 Oct 2018 12:53:29 +0000 (UTC) Received: from f28server.default (ovpn-116-135.phx2.redhat.com [10.3.116.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4677A6530E; Mon, 8 Oct 2018 12:53:24 +0000 (UTC) From: Daniel Bristot de Oliveira To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Greg Kroah-Hartman , Pavel Tatashin , Masami Hiramatsu , "Steven Rostedt (VMware)" , Zhou Chengming , Jiri Kosina , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Chris von Recklinghausen , Jason Baron , Scott Wood , Marcelo Tosatti , Clark Williams Subject: [RFC PATCH 1/6] jump_label: Add for_each_label_entry helper Date: Mon, 8 Oct 2018 14:53:00 +0200 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 08 Oct 2018 12:53:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the helper: for_each_label_entry(key, entry, stop) For the "for each jump label entry" for defined as: for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) Simplifying the reading and usage. Signed-off-by: Daniel Bristot de Oliveira Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Greg Kroah-Hartman Cc: Pavel Tatashin Cc: Masami Hiramatsu Cc: "Steven Rostedt (VMware)" Cc: Zhou Chengming Cc: Jiri Kosina Cc: Josh Poimboeuf Cc: "Peter Zijlstra (Intel)" Cc: Chris von Recklinghausen Cc: Jason Baron Cc: Scott Wood Cc: Marcelo Tosatti Cc: Clark Williams Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- include/linux/jump_label.h | 3 +++ kernel/jump_label.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 1a0b6f17a5d6..cd3bed880ca0 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -170,6 +170,9 @@ extern void static_key_disable(struct static_key *key); extern void static_key_enable_cpuslocked(struct static_key *key); extern void static_key_disable_cpuslocked(struct static_key *key); +#define for_each_label_entry(key, entry, stop) \ + for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) + /* * We should be using ATOMIC_INIT() for initializing .enabled, but * the inclusion of atomic.h is problematic for inclusion of jump_label.h diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 2e62503bea0d..e853916a3b46 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -365,7 +365,7 @@ static void __jump_label_update(struct static_key *key, struct jump_entry *entry, struct jump_entry *stop) { - for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) { + for_each_label_entry(key, entry, stop) { /* * An entry->code of 0 indicates an entry which has been * disabled because it was in an init text area. -- 2.17.1