From patchwork Mon Mar 30 05:17:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 46463 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3668A2159F for ; Mon, 30 Mar 2015 05:17:54 +0000 (UTC) Received: by ykef74 with SMTP id f74sf104382799yke.0 for ; Sun, 29 Mar 2015 22:17:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=vII8/vRWLaQPtmKzBr47UUz7Sx+1eeEbx0srk6FQRTI=; b=XntIfQLno9dS+48ARZ3TgEI/HUUPeBD+gbmS1TV2IzC2zhTtsTjF9bBmFDkaPPX2Ms k9e+mYqS8j62v60Gr7iEz9pcBgKFDPL2J4o1uL+NGFU1cXcI23C9adVBhYcRQLrpGUSa JUgGcTOCqtwj+RMrX5fV5KNAHwyjgbPqECHSh/EfEno3GmtMR2qIxPq245vATsgSCyf/ KZv5++Ndexg5UWxt27oeVgygMKJN/YD0CnE1i0SbU08oKdswyKYq0tC9MjRtBFX9id01 z7l9ldxx93pPn0QsTQyzvsaWKTA1jQR6XNhAm68EnmjTWAp29LM7gOuNgAR4W1WFwID9 NUfg== X-Gm-Message-State: ALoCoQkMpYekrZyCfzR71fRV7vM4mJRYfSW6ZVCT8ueuLTQmoS//oXdYBGFSpzjqkzVpcZRDzWNW X-Received: by 10.236.222.103 with SMTP id s97mr36642898yhp.19.1427692673999; Sun, 29 Mar 2015 22:17:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.10 with SMTP id l10ls2021841qge.73.gmail; Sun, 29 Mar 2015 22:17:53 -0700 (PDT) X-Received: by 10.140.130.71 with SMTP id 68mr40505201qhc.12.1427692673879; Sun, 29 Mar 2015 22:17:53 -0700 (PDT) Received: from mail-qc0-f174.google.com (mail-qc0-f174.google.com. [209.85.216.174]) by mx.google.com with ESMTPS id 3si9431789qhx.4.2015.03.29.22.17.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Mar 2015 22:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.174 as permitted sender) client-ip=209.85.216.174; Received: by qcgx3 with SMTP id x3so4744219qcg.3 for ; Sun, 29 Mar 2015 22:17:53 -0700 (PDT) X-Received: by 10.140.144.3 with SMTP id 3mr39783136qhq.34.1427692673698; Sun, 29 Mar 2015 22:17:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.96.155.231 with SMTP id vz7csp1204622qdb; Sun, 29 Mar 2015 22:17:52 -0700 (PDT) X-Received: by 10.66.55.42 with SMTP id o10mr13168075pap.148.1427692672476; Sun, 29 Mar 2015 22:17:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj13si13174346pdb.149.2015.03.29.22.17.46; Sun, 29 Mar 2015 22:17:52 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbbC3FRg (ORCPT + 27 others); Mon, 30 Mar 2015 01:17:36 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35110 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751586AbbC3FRa (ORCPT ); Mon, 30 Mar 2015 01:17:30 -0400 Received: by patj18 with SMTP id j18so265717pat.2 for ; Sun, 29 Mar 2015 22:17:30 -0700 (PDT) X-Received: by 10.68.226.161 with SMTP id rt1mr54643525pbc.101.1427692650097; Sun, 29 Mar 2015 22:17:30 -0700 (PDT) Received: from localhost ([122.167.118.120]) by mx.google.com with ESMTPSA id qj3sm9101473pac.31.2015.03.29.22.17.28 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 29 Mar 2015 22:17:29 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra , Thomas Gleixner Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 1/3] timer: Allocate per-cpu tvec_base's statically Date: Mon, 30 Mar 2015 10:47:17 +0530 Message-Id: X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.216.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Peter Zijlstra Memory for tvec_base is allocated separately for boot CPU (statically) and non-boot CPUs (dynamically). The reason is because __TIMER_INITIALIZER() needs to set ->base to a valid pointer (because we've made NULL special, hint: lock_timer_base()) and we cannot get a compile time pointer to per-cpu entries because we don't know where we'll map the section, even for the boot cpu. This can be simplified a bit by statically allocating per-cpu memory. The only disadvantage is that memory for one of the structures will stay unused, i.e. for the boot CPU, which uses boot_tvec_bases. This will also guarantee that tvec_base is cacheline aligned. Even though tvec_base has ____cacheline_aligned stuck on, kzalloc_node() does not actually respect that (but guarantees a minimum u64 alignment). Signed-off-by: Peter Zijlstra Signed-off-by: Viresh Kumar --- kernel/time/timer.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 2d3f5c504939..6e8220ec8a62 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -93,6 +93,7 @@ struct tvec_base { struct tvec_base boot_tvec_bases; EXPORT_SYMBOL(boot_tvec_bases); static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases; +static DEFINE_PER_CPU(struct tvec_base, __tvec_bases); /* Functions below help us manage 'deferrable' flag */ static inline unsigned int tbase_get_deferrable(struct tvec_base *base) @@ -1534,46 +1535,25 @@ EXPORT_SYMBOL(schedule_timeout_uninterruptible); static int init_timers_cpu(int cpu) { - int j; - struct tvec_base *base; + struct tvec_base *base = per_cpu(tvec_bases, cpu); static char tvec_base_done[NR_CPUS]; + int j; if (!tvec_base_done[cpu]) { static char boot_done; - if (boot_done) { - /* - * The APs use this path later in boot - */ - base = kzalloc_node(sizeof(*base), GFP_KERNEL, - cpu_to_node(cpu)); - if (!base) - return -ENOMEM; - - /* Make sure tvec_base has TIMER_FLAG_MASK bits free */ - if (WARN_ON(base != tbase_get_base(base))) { - kfree(base); - return -ENOMEM; - } - per_cpu(tvec_bases, cpu) = base; + if (!boot_done) { + boot_done = 1; /* skip the boot cpu */ } else { - /* - * This is for the boot CPU - we use compile-time - * static initialisation because per-cpu memory isn't - * ready yet and because the memory allocators are not - * initialised either. - */ - boot_done = 1; - base = &boot_tvec_bases; + base = per_cpu_ptr(&__tvec_bases, cpu); + per_cpu(tvec_bases, cpu) = base; } + spin_lock_init(&base->lock); tvec_base_done[cpu] = 1; base->cpu = cpu; - } else { - base = per_cpu(tvec_bases, cpu); } - for (j = 0; j < TVN_SIZE; j++) { INIT_LIST_HEAD(base->tv5.vec + j); INIT_LIST_HEAD(base->tv4.vec + j);