Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2498046ybh; Mon, 16 Mar 2020 04:28:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv9o7e41KsjyJEegsRzY+FZer+Ovtn2v6ziwICXKLVdUkAcq7mDHQWsdJWamyy5K3j4wFUV X-Received: by 2002:a9d:4c15:: with SMTP id l21mr22838049otf.185.1584358132841; Mon, 16 Mar 2020 04:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584358132; cv=none; d=google.com; s=arc-20160816; b=mJaEKmG8DRe0foXNPQXghNqXLPpFKnASRjpsmWaRZUeLzbDuZ+v6sNCfc9hkakZtu2 SEMVBRroxcGGjMNArQO0Ap0f2q0FGl2W80moz6M3geXj5WOcRvGOgBNnP2jC5/OrPaqp ncl0+CvErGB+QBd5ZQEjkpcjpENXglo7u9/iOnfkMaZrParmKGX1tA9c+6e7LCGHFQD6 /JX13htriZ88Veo4g7DcgeNpKvL9EOa08aumMW88KGqWtFDwuDZfBkHw6cmfl/abscAq VLnCnfhWKEbm0daDm93oTLs5qGg+qhHKMrnFwoDAqmQfC5pHTDFBglKALghPm7ZEwWyd D6xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dmarc-filter:dkim-signature; bh=8AhoRulK+Wx1g03sgzSt5h6cmvFffKNX5bBFnXkzqcY=; b=b3yY/MZIPX6EdqbFoshFBhg1y0RDfRCZ4/xqupDT6PBQDmsppRAQNRjkWpAcnbeExZ awf/TfrrygH01lqTInl0lnd3Fk1belTJVxJCP9WXFh6mcXVdAXtR6mAtKGsYPcTmmyH/ y/TwD6VIAuLsUTFXQ5lu9LnhBcWzt+vdmK9pm8rBOLPoljCbim8mbWlGUT3r0mY2PoDD pSolWxrWAzcoVTTEHxWf3mNFJtDZIcit4zppU5BWbSRw0S8llzOfA4HW44FLHrlM3MIc 6/OqHM089Qn4DVHPEEOAQNcPBzd7WUd5dRbFcQSv5RCEpngFo9UcRpGpEQmrJ03XbOo0 OAsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=xahOxVv4; 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 m4si9770717otk.132.2020.03.16.04.28.38; Mon, 16 Mar 2020 04:28:52 -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=@mg.codeaurora.org header.s=smtp header.b=xahOxVv4; 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 S1730786AbgCPL1u (ORCPT + 99 others); Mon, 16 Mar 2020 07:27:50 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:57980 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729043AbgCPL1u (ORCPT ); Mon, 16 Mar 2020 07:27:50 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1584358069; h=Content-Type: Cc: To: Subject: Message-ID: Date: From: In-Reply-To: References: MIME-Version: Sender; bh=8AhoRulK+Wx1g03sgzSt5h6cmvFffKNX5bBFnXkzqcY=; b=xahOxVv4mPohHuMR1TUdI2JVDl83VG/BJB3SFhQjpbwkFCTk9IrvymIa7AD9cEcnWwIVnwGs bxIMNsOspHIqdrt3z/DSfpu2+r4XD5qHK8a6d8DnsbtPoVfrgEGX235D1sTWL0PhbGEJvihy pPKVfD+EZp4HRcflhTBiEAvk6G0= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e6f62a6.7f675edb7378-smtp-out-n02; Mon, 16 Mar 2020 11:27:34 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 27F90C44788; Mon, 16 Mar 2020 11:27:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pkondeti) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6D99EC433D2 for ; Mon, 16 Mar 2020 11:27:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6D99EC433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pkondeti@codeaurora.org Received: by mail-ed1-f47.google.com with SMTP id b23so21585301edx.4 for ; Mon, 16 Mar 2020 04:27:32 -0700 (PDT) X-Gm-Message-State: ANhLgQ3A2Y0lYOQIYrUz7QibaQruPGbxe7/IxTljqFAbYv0/CFWYct5k fQMBYZEXGvPBBM62fN0GVZ2FQmo/DXhrUaPSOws= X-Received: by 2002:a50:951e:: with SMTP id u30mr25583228eda.144.1584358051134; Mon, 16 Mar 2020 04:27:31 -0700 (PDT) MIME-Version: 1.0 References: <1584326350-30275-1-git-send-email-psodagud@codeaurora.org> <1584326350-30275-3-git-send-email-psodagud@codeaurora.org> In-Reply-To: <1584326350-30275-3-git-send-email-psodagud@codeaurora.org> From: Pavan Kondeti Date: Mon, 16 Mar 2020 16:57:19 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] sched: Add a check for cpu unbound deferrable timers To: Prasad Sodagudi Cc: John Stultz , Thomas Gleixner , sboyd@kernel.org, LKML , saravanak@google.com, tsoni@codeaurora.org, Tejun Heo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prasad, On Mon, Mar 16, 2020 at 8:42 AM Prasad Sodagudi wrote: > > Add a check for cpu unbound deferrable timer expiry and raise > softirq for handling the expired timers so that the CPU can > process the cpu unbound deferrable times as early as possible > when a cpu tries to enter/exit idle loop. > > Signed-off-by: Prasad Sodagudi > --- > include/linux/timer.h | 3 +++ > kernel/time/tick-sched.c | 6 ++++++ > kernel/time/timer.c | 29 ++++++++++++++++++++++++++++- > 3 files changed, 37 insertions(+), 1 deletion(-) > > diff --git a/include/linux/timer.h b/include/linux/timer.h > index 1e6650e..25a1837 100644 > --- a/include/linux/timer.h > +++ b/include/linux/timer.h > @@ -172,6 +172,9 @@ extern int del_timer(struct timer_list * timer); > extern int mod_timer(struct timer_list *timer, unsigned long expires); > extern int mod_timer_pending(struct timer_list *timer, unsigned long expires); > extern int timer_reduce(struct timer_list *timer, unsigned long expires); > +#ifdef CONFIG_SMP > +extern bool check_pending_deferrable_timers(int cpu); > +#endif > > /* > * The jiffies value which is added to now, when there is no timer > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index a792d21..fe0836a 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -948,6 +949,11 @@ static void __tick_nohz_idle_stop_tick(struct tick_sched *ts) > ktime_t expires; > int cpu = smp_processor_id(); > > +#ifdef CONFIG_SMP > + if (check_pending_deferrable_timers(cpu)) > + raise_softirq_irqoff(TIMER_SOFTIRQ); > +#endif > + > /* > * If tick_nohz_get_sleep_length() ran tick_nohz_next_event(), the > * tick timer expiration time is known already. Since this is called outside interrupt context, ksoftirqd task is always woken up to serve the TIMER softirq. Given that, this CPU exited idle due to an interrupt, we could probably check this condition and raise the softirq prior to irq_exit. To make the discussion easier, providing the diff. This will make sure that TIMER softirq is served after serving the IRQ and avoids waking ksoftirqd. This should also cover the case, Thoms mentioned in the other email. diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index a792d21..d9d1915 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1268,8 +1268,19 @@ static inline void tick_nohz_irq_enter(void) now = ktime_get(); if (ts->idle_active) tick_nohz_stop_idle(ts, now); - if (ts->tick_stopped) + if (ts->tick_stopped) { tick_nohz_update_jiffies(now); + /* + * TODO: check the possibility of doing this only + * when jiffies is updated. + * + * __raise_softirq_irqoff() marks the softirq pending. + * The softirq is served after this IRQ is served from + * irq_exit() + */ + if (check_pending_deferrable_timers()) + __raise_softirq_irqoff(TIMER_SOFTIRQ); + } } #else -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project