Received: by 10.223.185.116 with SMTP id b49csp512285wrg; Fri, 16 Feb 2018 02:45:39 -0800 (PST) X-Google-Smtp-Source: AH8x225I32gToBWWPkOysQ2fH1pK1rzUKfvJxGkInvtsZOpfO+aK9iymli8U+t/2mR9F486ItB3a X-Received: by 10.99.173.73 with SMTP id y9mr4769841pgo.432.1518777939131; Fri, 16 Feb 2018 02:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518777939; cv=none; d=google.com; s=arc-20160816; b=ikLHRPf+05GOTFuMnxOU0PPlMH9XhnKD7ysFupNUsbC5+afme2YvyQ0Bp5AbTpqEIs 8Y0mR6yBp6pR8yMrxlzsCsG5AldvcZDiWRTFEIWMa+uLv1pv/c8jr4NsaxVVuYW7uy9s SLxeIy9YxWgGm/u68JoL5u3eIiQk294ryr72b3bA6adoZGBQEQDfMVk+tGvyJto609lK ZuxO4pnOzknV1XDayLSi4PKDLjWwEfkAuDyBLsl3oUEe33nGUbsjlYHcNunANNXuEGur K4hgV4tlhsWbDOzwwRSvRoRAvWA8vLRACDQcBKZGaFIk7TTGLfuixlLCk9KbGiJ4agGG TcrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OY/HIK1OGZiElmV6TT63OKb8at8Cf1b65ef2sqoxHak=; b=n3iNglA+T2A0jsX/iWgra1n1jQ4Ydc+W8vG493XW5ENntKhrhbBtTNyTRprRHVZwnf 19E4TgB5nzeRPE9j227m4OtxZmeGH7Jky7DQdTNWbdEpiDM0Pb1ekIS4fE5QXOMidXc7 OnRy844OAJ03UvBM6+jJzEGb6m+ACoiVbPspkEfIYZLKhWX1aqasaB/O/ej3m2wYPJy5 60EoJ3ayHdcEs4ZJYHsNpScFkOVy1YDWRon3VRvfO3LtwC3r6xnGc7Cohzcpaon9yBOS UohgbDzGoR9cXRRJEFowrRvFABZN7LESEeIBuKiuw+LJKDE0JpNP4eCcxTQR2vQoNdQu IVWA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si858424pgv.201.2018.02.16.02.45.24; Fri, 16 Feb 2018 02:45:39 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427253AbeBORVV (ORCPT + 99 others); Thu, 15 Feb 2018 12:21:21 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:54906 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422692AbeBORVU (ORCPT ); Thu, 15 Feb 2018 12:21:20 -0500 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1emNAY-0003Wd-B5; Thu, 15 Feb 2018 18:18:02 +0100 From: Sebastian Andrzej Siewior To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org, tglx@linutronix.de, Ingo Molnar , Sebastian Andrzej Siewior Subject: [PATCH 2/2] kernel/sofirq: consolidate common code in tasklet_action() + tasklet_hi_action() Date: Thu, 15 Feb 2018 18:20:42 +0100 Message-Id: <20180215172042.31573-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215172042.31573-1-bigeasy@linutronix.de> References: <20180215172042.31573-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ingo Molnar tasklet_action() + tasklet_hi_action() are almost identical. Move the common code from both function into __tasklet_schedule_common() and let both functions invoke it with different arguments. Signed-off-by: Ingo Molnar Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner [bigeasy: splitted out from RT's "tasklet: Prevent tasklets from going into infinite spin in RT" and added commit message] Signed-off-by: Sebastian Andrzej Siewior --- kernel/softirq.c | 54 +++++++++++++++-------------------------------------= -- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/kernel/softirq.c b/kernel/softirq.c index 145cf6a2e7c9..fa7ed89a9fcf 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -488,14 +488,16 @@ void __tasklet_hi_schedule(struct tasklet_struct *t) } EXPORT_SYMBOL(__tasklet_hi_schedule); =20 -static __latent_entropy void tasklet_action(struct softirq_action *a) +static void tasklet_action_common(struct softirq_action *a, + struct tasklet_head *tl_head, + unsigned int softirq_nr) { struct tasklet_struct *list; =20 local_irq_disable(); - list =3D __this_cpu_read(tasklet_vec.head); - __this_cpu_write(tasklet_vec.head, NULL); - __this_cpu_write(tasklet_vec.tail, this_cpu_ptr(&tasklet_vec.head)); + list =3D tl_head->head; + tl_head->head =3D NULL; + tl_head->tail =3D &tl_head->head; local_irq_enable(); =20 while (list) { @@ -517,47 +519,21 @@ static __latent_entropy void tasklet_action(struct so= ftirq_action *a) =20 local_irq_disable(); t->next =3D NULL; - *__this_cpu_read(tasklet_vec.tail) =3D t; - __this_cpu_write(tasklet_vec.tail, &(t->next)); - __raise_softirq_irqoff(TASKLET_SOFTIRQ); + *tl_head->tail =3D t; + tl_head->tail =3D &t->next; + __raise_softirq_irqoff(softirq_nr); local_irq_enable(); } } =20 +static __latent_entropy void tasklet_action(struct softirq_action *a) +{ + tasklet_action_common(a, this_cpu_ptr(&tasklet_vec), TASKLET_SOFTIRQ); +} + static __latent_entropy void tasklet_hi_action(struct softirq_action *a) { - struct tasklet_struct *list; - - local_irq_disable(); - list =3D __this_cpu_read(tasklet_hi_vec.head); - __this_cpu_write(tasklet_hi_vec.head, NULL); - __this_cpu_write(tasklet_hi_vec.tail, this_cpu_ptr(&tasklet_hi_vec.head)); - local_irq_enable(); - - while (list) { - struct tasklet_struct *t =3D list; - - list =3D list->next; - - if (tasklet_trylock(t)) { - if (!atomic_read(&t->count)) { - if (!test_and_clear_bit(TASKLET_STATE_SCHED, - &t->state)) - BUG(); - t->func(t->data); - tasklet_unlock(t); - continue; - } - tasklet_unlock(t); - } - - local_irq_disable(); - t->next =3D NULL; - *__this_cpu_read(tasklet_hi_vec.tail) =3D t; - __this_cpu_write(tasklet_hi_vec.tail, &(t->next)); - __raise_softirq_irqoff(HI_SOFTIRQ); - local_irq_enable(); - } + tasklet_action_common(a, this_cpu_ptr(&tasklet_hi_vec), HI_SOFTIRQ); } =20 void tasklet_init(struct tasklet_struct *t, --=20 2.16.1