Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp83809ybj; Wed, 6 May 2020 12:06:45 -0700 (PDT) X-Google-Smtp-Source: APiQypLwJMy/9uVCir3fLJc8ndntOxy4QWvNWzFDYE3jDkuAWTiDjMvhNJNAj+c+qgb4Pksrf71W X-Received: by 2002:aa7:de0b:: with SMTP id h11mr8549096edv.133.1588792005557; Wed, 06 May 2020 12:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588792005; cv=none; d=google.com; s=arc-20160816; b=O4pGbhegzg7eKKr4ZzqAexFGw0Wqq7POcFZMyBGrcTbcE5xB5E6IBfXtj5/Z9WsMQw ywRmUoszOW5ps4n7QFbE8ZZksOxArAK1+WoazEEycR4JbmRzJogv0049l93BOuJd/Osk T+xQ5xNosHLKfMXl0fkuHnNQHg6mpqZehS7bt7DdiLM+ucGTnBw9fjpTOtDB6e71MmgZ BfGWzXdpwuspcmuvHyQatxNWBjdFgRQXahf4ahQxZlaqtU/dLplc62OUQR7LQHgVmdFQ U1MJvYDd8nRY3mYAe6lDkeLu0da7oqxs85QJxVdiRYxVTVqw+ayTGO3Bi4t2oieJh+60 dRqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=fyZpqyNa97AXpZfTSu6i5j6WEMyIXKHW0oLCbwufbXs=; b=TRein8ENGh0hFZT9SRJeRzlt0A2wYRcQugQplAdprtPVX3q6oA8ro7ZpMDKgUPBYFH T6TbuxNXG6dlVH4zn0sFWt3/f8HecqGLiraUov8Ym+v0C27uNDLXrClPKxjxcCPKQwTR Gln9G+L3ZU6WskwLFVTRTqvQ7ElIOl5SYyGGRDuw+TvaUtll9+HFBLWS+4uU99oWu1vs UhTGcrLKBlLEhKNza0acn4HJaxxcBOKM9Fmg4asIp0QFM80459vSclKlwXg6jTJo/sHq rKO8JtV8r5oAywhm1dkZ3gn3XpC2gnPC0wjaCZhpEIK1yiegBWbdkUHbLU1fwUTJcP6b OmsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si1680480edq.470.2020.05.06.12.06.21; Wed, 06 May 2020 12:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728392AbgEFN2w (ORCPT + 99 others); Wed, 6 May 2020 09:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728081AbgEFN2w (ORCPT ); Wed, 6 May 2020 09:28:52 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C75C061A0F for ; Wed, 6 May 2020 06:28:52 -0700 (PDT) Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jWK6R-0003dl-6S; Wed, 06 May 2020 15:28:47 +0200 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 32FCA1001F5; Wed, 6 May 2020 15:28:46 +0200 (CEST) From: Thomas Gleixner To: Prasad Sodagudi , john.stultz@linaro.org, sboyd@kernel.org, tj@kernel.org Cc: linux-kernel@vger.kernel.org, saravanak@google.com, psodagud@codeaurora.org, pkondeti@codeaurora.org, Joonwoo Park Subject: Re: [PATCH v3 1/2] timer: make deferrable cpu unbound timers really not bound to a cpu In-Reply-To: <1588444137-18651-2-git-send-email-psodagud@codeaurora.org> References: <1588444137-18651-1-git-send-email-psodagud@codeaurora.org> <1588444137-18651-2-git-send-email-psodagud@codeaurora.org> Date: Wed, 06 May 2020 15:28:46 +0200 Message-ID: <87a72lkx9t.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prasad Sodagudi writes: > To make all cpu unbound deferrable timers are scalable, introduce a common > timer base which is only for cpu unbound deferrable timers to make those > are indeed cpu unbound so that can be scheduled by any of non idle cpus. > This common timer fixes scalability issue of delayed work and all other cpu > unbound deferrable timer using implementations. Scalability? That's really the wrong term here. A global timer base is the opposite and you really want to explain why this is not creating a scalability problem on large systems. > #ifdef CONFIG_SMP > +struct timer_base timer_base_deferrable; > unsigned int sysctl_timer_migration = 1; > > DEFINE_STATIC_KEY_FALSE(timers_migration_enabled); > @@ -841,8 +842,14 @@ static inline struct timer_base *get_timer_cpu_base(u32 tflags, u32 cpu) > * If the timer is deferrable and NO_HZ_COMMON is set then we need > * to use the deferrable base. > */ > - if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && (tflags & TIMER_DEFERRABLE)) > - base = per_cpu_ptr(&timer_bases[BASE_DEF], cpu); > + if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && (tflags & TIMER_DEFERRABLE)) { > +#ifdef CONFIG_SMP > + base = &timer_base_deferrable; > +#endif There are definitely smarter ways of solving this than sprinkling #ifdef's around the code. > + if (tflags & TIMER_PINNED) > + base = per_cpu_ptr(&timer_bases[BASE_DEF], cpu); > + } > + > return base; > } > @@ -1785,8 +1798,14 @@ static __latent_entropy void run_timer_softirq(struct softirq_action *h) > struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); > > __run_timers(base); > - if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) > + if (IS_ENABLED(CONFIG_NO_HZ_COMMON)) { > __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF])); > +#ifdef CONFIG_SMP > + if (tick_do_timer_cpu == TICK_DO_TIMER_NONE || > + tick_do_timer_cpu == smp_processor_id()) > + __run_timers(&timer_base_deferrable); > +#endif Again, this can be solved in readable ways. Just slapping #ifdefs all over the place is sloppy and lazy. Aside of that accessing the tick internals here open coded is just a layering violation. > + } > } > > /* > @@ -2025,6 +2044,16 @@ static void __init init_timer_cpu(int cpu) > } > } > > +#if defined(CONFIG_NO_HZ_COMMON) && defined(CONFIG_SMP) > +static void __init init_timer_deferrable_global(void) > +{ > + timer_base_deferrable.cpu = nr_cpu_ids; This was obviously never tested with CONFIG_DEBUG_PER_CPU_MAPS=y as this will simply result in out of bounds accesses. > static void __init init_timer_cpus(void) > { > int cpu; > @@ -2036,6 +2065,9 @@ static void __init init_timer_cpus(void) > void __init init_timers(void) > { > init_timer_cpus(); > +#if defined(CONFIG_NO_HZ_COMMON) && defined(CONFIG_SMP) > + init_timer_deferrable_global(); > +#endif Stub functions exist to avoid this unreadable #ifdef garbage. Thanks, tglx