From patchwork Fri Jan 30 19:03:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 44062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D749124267 for ; Fri, 30 Jan 2015 19:03:34 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf3639073wiw.1 for ; Fri, 30 Jan 2015 11:03:34 -0800 (PST) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Jr0WCje/0OGDgZtoUz8aB61JfV456jlBADid3+fMC2w=; b=AuyYA7xaG/OWhB9UhCv/LAvXEnusne2nznscgvQNnmTifXayXRM+RU4I8GJVrgTEq5 v49xEzGvXn9JvLm7AMqlYc7fW4ISmIKxGshYwK+IOfNAYwOwKvk0HTh+t+xomA55a3La /UqabbYqbedta65nHiKxyFhbxoHxOYOTWWyb0L1RaKsI9TGmAopfK/u2gPviSO61jjpt ikBgk63k9ue94RsQb9/ZltVNuI6v8kPd5Rfq7spobuFUrHT+AxCVVlqy6lfF8YkEO3Ee 0PmjNCzTntVcpmGgEwe772PyKItj9TWNxwWwOdEoyluSDQ3B2SJ1N8aREKm9Z62NIN7X ng6w== X-Gm-Message-State: ALoCoQmZLVS6FJxpb3nl8XrQMyoDtFlgydAarTKt9zPgH2/Z8nA7arl0Kdy5ow9PW1UAPgdzJCuY X-Received: by 10.180.108.197 with SMTP id hm5mr27627wib.4.1422644614173; Fri, 30 Jan 2015 11:03:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.97 with SMTP id z1ls472751laz.35.gmail; Fri, 30 Jan 2015 11:03:33 -0800 (PST) X-Received: by 10.112.132.67 with SMTP id os3mr7994513lbb.90.1422644613868; Fri, 30 Jan 2015 11:03:33 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id ll2si1585065lac.39.2015.01.30.11.03.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 11:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id ge10so25380473lab.11 for ; Fri, 30 Jan 2015 11:03:33 -0800 (PST) X-Received: by 10.112.243.12 with SMTP id wu12mr8067084lbc.91.1422644613683; Fri, 30 Jan 2015 11:03:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.35.133 with SMTP id h5csp380588lbj; Fri, 30 Jan 2015 11:03:33 -0800 (PST) X-Received: by 10.194.93.134 with SMTP id cu6mr17934wjb.79.1422644613128; Fri, 30 Jan 2015 11:03:33 -0800 (PST) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com. [74.125.82.177]) by mx.google.com with ESMTPS id bg8si208837wjc.132.2015.01.30.11.03.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 11:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 74.125.82.177 as permitted sender) client-ip=74.125.82.177; Received: by mail-we0-f177.google.com with SMTP id l61so28771265wev.8 for ; Fri, 30 Jan 2015 11:03:32 -0800 (PST) X-Received: by 10.180.100.202 with SMTP id fa10mr497259wib.10.1422644612848; Fri, 30 Jan 2015 11:03:32 -0800 (PST) Received: from sundance.lan (cpc4-aztw19-0-0-cust157.18-1.cable.virginm.net. [82.33.25.158]) by mx.google.com with ESMTPSA id d6sm8166187wic.1.2015.01.30.11.03.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jan 2015 11:03:32 -0800 (PST) From: Daniel Thompson To: Thomas Gleixner , John Stultz Cc: Daniel Thompson , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Sumit Semwal , Stephen Boyd , Steven Rostedt , Russell King , Will Deacon , Catalin Marinas Subject: [PATCH v3 3/4] sched_clock: Remove suspend from clock_read_data Date: Fri, 30 Jan 2015 19:03:21 +0000 Message-Id: <1422644602-11953-4-git-send-email-daniel.thompson@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1422644602-11953-1-git-send-email-daniel.thompson@linaro.org> References: <1421859236-19782-1-git-send-email-daniel.thompson@linaro.org> <1422644602-11953-1-git-send-email-daniel.thompson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.thompson@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.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently cd.read_data.suspended is read by the hotpath function sched_clock(). This variable need not be accessed on the hotpath; we can instead check whether the timer is suspended by checking the validity of the read_sched_clock function pointer. The new master copy of the function pointer (actual_read_sched_clock) is introduced and is used this for all reads of the clock hardware except those within sched_clock itself. Suggested-by: Thomas Gleixner Signed-off-by: Daniel Thompson Cc: Russell King Cc: Will Deacon Cc: Catalin Marinas --- kernel/time/sched_clock.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index cb69a47dfee4..638c765131fa 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -22,7 +22,7 @@ * struct clock_read_data - data required to read from sched_clock * * Care must be taken when updating this structure; it is read by - * some very hot code paths. It occupies <=48 bytes and, when combined + * some very hot code paths. It occupies <=40 bytes and, when combined * with the seqcount used to synchronize access, comfortably fits into * a 64 byte cache line. */ @@ -33,7 +33,6 @@ struct clock_read_data { u64 (*read_sched_clock)(void); u32 mult; u32 shift; - bool suspended; }; /** @@ -49,6 +48,7 @@ struct clock_data { struct clock_read_data read_data; ktime_t wrap_kt; unsigned long rate; + u64 (*actual_read_sched_clock)(void); }; static struct hrtimer sched_clock_timer; @@ -68,6 +68,8 @@ static u64 notrace jiffy_sched_clock_read(void) static struct clock_data cd ____cacheline_aligned = { .read_data = { .mult = NSEC_PER_SEC / HZ, .read_sched_clock = jiffy_sched_clock_read, }, + .actual_read_sched_clock = jiffy_sched_clock_read, + }; static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift) @@ -85,7 +87,7 @@ unsigned long long notrace sched_clock(void) seq = raw_read_seqcount_begin(&cd.seq); res = rd->epoch_ns; - if (!rd->suspended) { + if (rd->read_sched_clock) { cyc = rd->read_sched_clock(); cyc = (cyc - rd->epoch_cyc) & rd->sched_clock_mask; res += cyc_to_ns(cyc, rd->mult, rd->shift); @@ -105,7 +107,7 @@ static void notrace update_sched_clock(void) u64 ns; struct clock_read_data *rd = &cd.read_data; - cyc = rd->read_sched_clock(); + cyc = cd.actual_read_sched_clock(); ns = rd->epoch_ns + cyc_to_ns((cyc - rd->epoch_cyc) & rd->sched_clock_mask, rd->mult, rd->shift); @@ -151,10 +153,11 @@ void __init sched_clock_register(u64 (*read)(void), int bits, /* update epoch for new counter and update epoch_ns from old counter*/ new_epoch = read(); - cyc = rd->read_sched_clock(); + cyc = cd.actual_read_sched_clock(); ns = rd->epoch_ns + cyc_to_ns((cyc - rd->epoch_cyc) & rd->sched_clock_mask, rd->mult, rd->shift); + cd.actual_read_sched_clock = read; raw_write_seqcount_begin(&cd.seq); rd->read_sched_clock = read; @@ -194,7 +197,7 @@ void __init sched_clock_postinit(void) * If no sched_clock function has been provided at that point, * make it the final one one. */ - if (cd.read_data.read_sched_clock == jiffy_sched_clock_read) + if (cd.actual_read_sched_clock == jiffy_sched_clock_read) sched_clock_register(jiffy_sched_clock_read, BITS_PER_LONG, HZ); update_sched_clock(); @@ -214,7 +217,7 @@ static int sched_clock_suspend(void) update_sched_clock(); hrtimer_cancel(&sched_clock_timer); - rd->suspended = true; + rd->read_sched_clock = NULL; return 0; } @@ -222,9 +225,9 @@ static void sched_clock_resume(void) { struct clock_read_data *rd = &cd.read_data; - rd->epoch_cyc = rd->read_sched_clock(); + rd->epoch_cyc = cd.actual_read_sched_clock(); hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); - rd->suspended = false; + rd->read_sched_clock = cd.actual_read_sched_clock; } static struct syscore_ops sched_clock_ops = {