From patchwork Thu Sep 3 23:49:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 53062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 3758722E23 for ; Thu, 3 Sep 2015 23:50:14 +0000 (UTC) Received: by lagj9 with SMTP id j9sf1689164lag.0 for ; Thu, 03 Sep 2015 16:50:12 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=GKoeVTCSkzQFS2LiVJPuNDlQsXG7k6km7CdoQnF1ySg=; b=b2clp6eOYjvaEE0+4+IuXEQ9jvbHGK5B1hchAXc1EI6hr/V9ZUBUqRWtmxea8Vv5NW J9lP35VZbBIbsadRMUF6yQfAJwmZifAKbgVvgHUrT1rLo0vCbAgkWcA0AME3OXnVZ5mN LMj3cUijAV8mxCvBhNdYH9uwAHdlfA/h62v8/byUC7VRuFo/LR8jOsMrgKW4OaZBK3oO pL+y0HGifffCSxQJpukK/1B2JokUp6xUWI8YWMSHQcajH1sXc3QTjR0c8SwtkL70lufT IGa6zHY95osbE5l6Tg+lqY3CSmRU6YK3PVsrcdsvT7Pg+uaMjrf8XAv0W6plodFHUWOx XiOA== X-Gm-Message-State: ALoCoQlTBOVIbxtxEfbMut0NxCEpXFXQJPnbmgjMZwb6/dBa0Uwzo3FEHEz2AesS3Ld+MawMDdLh X-Received: by 10.112.99.37 with SMTP id en5mr148271lbb.7.1441324212893; Thu, 03 Sep 2015 16:50:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.2 with SMTP id wm2ls239936lac.38.gmail; Thu, 03 Sep 2015 16:50:12 -0700 (PDT) X-Received: by 10.112.91.196 with SMTP id cg4mr635782lbb.10.1441324212711; Thu, 03 Sep 2015 16:50:12 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id x2si514673lad.28.2015.09.03.16.50.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 16:50:12 -0700 (PDT) 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 lagj9 with SMTP id j9so3194799lag.2 for ; Thu, 03 Sep 2015 16:50:12 -0700 (PDT) X-Received: by 10.112.16.135 with SMTP id g7mr593263lbd.19.1441324212576; Thu, 03 Sep 2015 16:50:12 -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.112.164.42 with SMTP id yn10csp1584912lbb; Thu, 3 Sep 2015 16:50:11 -0700 (PDT) X-Received: by 10.107.25.134 with SMTP id 128mr1460503ioz.159.1441324211674; Thu, 03 Sep 2015 16:50:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si883368pdi.79.2015.09.03.16.50.10; Thu, 03 Sep 2015 16:50:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753615AbbICXuJ (ORCPT + 4 others); Thu, 3 Sep 2015 19:50:09 -0400 Received: from mail-lb0-f172.google.com ([209.85.217.172]:35943 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753011AbbICXuI (ORCPT ); Thu, 3 Sep 2015 19:50:08 -0400 Received: by lbcao8 with SMTP id ao8so2616684lbc.3 for ; Thu, 03 Sep 2015 16:50:07 -0700 (PDT) X-Received: by 10.152.5.169 with SMTP id t9mr590425lat.55.1441324207197; Thu, 03 Sep 2015 16:50:07 -0700 (PDT) Received: from localhost.localdomain ([46.39.50.164]) by smtp.gmail.com with ESMTPSA id ju7sm105324lbc.43.2015.09.03.16.50.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Sep 2015 16:50:06 -0700 (PDT) From: Alexey Klimov To: daniel.lezcano@linaro.org, k.kozlowski@samsung.com, linux-samsung-soc@vger.kernel.org Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, alexey.klimov@linaro.org, yury.norov@gmail.com, klimov.linux@gmail.com, kgene@kernel.org Subject: [RFC PATCH] clocksource: exynos_mct: use container_of() instead of this_cpu_ptr() Date: Fri, 4 Sep 2015 02:49:58 +0300 Message-Id: <1441324198-14513-1-git-send-email-alexey.klimov@linaro.org> X-Mailer: git-send-email 2.1.4 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alexey.klimov@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.mailfrom=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: , Since evt structure is embedded in per-CPU mevt structure it's definitely faster to use container_of() to get access to mevt if we have evt (for example as incoming function argument) instead of more expensive approach with this_cpu_ptr(&percpu_mct_tick). this_cpu_ptr() on per-CPU mevt structure leads to access to cp15 to get cpu id and arithmetic operations. Container_of() is cheaper since it's just one asm instruction. This should work if used evt pointer is correct and owned by local mevt structure. For example, before this patch set_state_shutdown() looks like: 4a4: e92d4010 push {r4, lr} 4a8: e3004000 movw r4, #0 4ac: ebfffffe bl 0 4b0: e3003000 movw r3, #0 4b4: e3404000 movt r4, #0 4b8: e3403000 movt r3, #0 4bc: e7933100 ldr r3, [r3, r0, lsl #2] 4c0: e0844003 add r4, r4, r3 4c4: e59400c0 ldr r0, [r4, #192] ; 0xc0 4c8: ebffffd4 bl 420 4cc: e3a00000 mov r0, #0 4d0: e8bd8010 pop {r4, pc} With this patch: 4a4: e92d4010 push {r4, lr} 4a8: e59000c0 ldr r0, [r0, #192] ; 0xc0 4ac: ebffffdb bl 420 4b0: e3a00000 mov r0, #0 4b4: e8bd8010 pop {r4, pc} Also, for me size of exynos_mct.o decreased from 84588 bytes to 83956. Signed-off-by: Alexey Klimov Reviewed-by: Krzysztof Kozlowski --- drivers/clocksource/exynos_mct.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index 029f96a..ff44082 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -382,24 +382,28 @@ static void exynos4_mct_tick_start(unsigned long cycles, static int exynos4_tick_set_next_event(unsigned long cycles, struct clock_event_device *evt) { - struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick); + struct mct_clock_event_device *mevt; + mevt = container_of(evt, struct mct_clock_event_device, evt); exynos4_mct_tick_start(cycles, mevt); - return 0; } static int set_state_shutdown(struct clock_event_device *evt) { - exynos4_mct_tick_stop(this_cpu_ptr(&percpu_mct_tick)); + struct mct_clock_event_device *mevt; + + mevt = container_of(evt, struct mct_clock_event_device, evt); + exynos4_mct_tick_stop(mevt); return 0; } static int set_state_periodic(struct clock_event_device *evt) { - struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick); + struct mct_clock_event_device *mevt; unsigned long cycles_per_jiffy; + mevt = container_of(evt, struct mct_clock_event_device, evt); cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult) >> evt->shift); exynos4_mct_tick_stop(mevt);