Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761412AbbBIWSi (ORCPT ); Mon, 9 Feb 2015 17:18:38 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:60050 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755818AbbBIWSg (ORCPT ); Mon, 9 Feb 2015 17:18:36 -0500 X-Greylist: delayed 593 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 Feb 2015 17:18:35 EST Message-ID: <54D92FE7.8070909@codeaurora.org> Date: Mon, 09 Feb 2015 14:08:39 -0800 From: Stephen Boyd User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Daniel Thompson CC: Thomas Gleixner , John Stultz , linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Sumit Semwal , Steven Rostedt Subject: Re: [PATCH v3 0/4] sched_clock: Optimize and avoid deadlock during read from NMI References: <1421859236-19782-1-git-send-email-daniel.thompson@linaro.org> <1422644602-11953-1-git-send-email-daniel.thompson@linaro.org> <20150205005034.GA30372@codeaurora.org> <54D33263.4060707@linaro.org> <54D751F9.10002@linaro.org> In-Reply-To: <54D751F9.10002@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5381 Lines: 138 On 02/08/15 04:09, Daniel Thompson wrote: > On 05/02/15 17:05, Daniel Thompson wrote: >> On 05/02/15 00:50, Stephen Boyd wrote: >>> On 01/30, Daniel Thompson wrote: >>>> This patchset optimizes the generic sched_clock implementation to >>>> significantly reduce the data cache profile. It also makes it safe to call >>>> sched_clock() from NMI (or FIQ on ARM). >>>> >>>> The data cache profile of sched_clock() in both the original code and >>>> my previous patch was somewhere between 2 and 3 (64-byte) cache lines, >>>> depending on alignment of struct clock_data. After patching, the cache >>>> profile for the normal case should be a single cacheline. >>>> >>>> NMI safety was tested on i.MX6 with perf drowning the system in FIQs and >>>> using the perf handler to check that sched_clock() returned monotonic >>>> values. At the same time I forcefully reduced kt_wrap so that >>>> update_sched_clock() is being called at >1000Hz. >>>> >>>> Without the patches the above system is grossly unstable, surviving >>>> [9K,115K,25K] perf event cycles during three separate runs. With the >>>> patch I ran for over 9M perf event cycles before getting bored. >>> I wanted to see if there was any speedup from these changes so I >>> made a tight loop around sched_clock() that ran for 10 seconds >>> and I ran it 10 times before and after this patch series: >>> >>> unsigned long long clock, start_clock; >>> int count = 0; >>> >>> clock = start_clock = sched_clock(); >>> while ((clock - start_clock) < 10ULL * NSEC_PER_SEC) { >>> clock = sched_clock(); >>> count++; >>> } >>> >>> pr_info("Made %d calls in %llu ns\n", count, clock - start_clock); >>> >>> Before >>> ------ >>> Made 19218953 calls in 10000000439 ns >>> Made 19212790 calls in 10000000438 ns >>> Made 19217121 calls in 10000000142 ns >>> Made 19227304 calls in 10000000142 ns >>> Made 19217559 calls in 10000000142 ns >>> Made 19230193 calls in 10000000290 ns >>> Made 19212715 calls in 10000000290 ns >>> Made 19234446 calls in 10000000438 ns >>> Made 19226274 calls in 10000000439 ns >>> Made 19236118 calls in 10000000143 ns >>> >>> After >>> ----- >>> Made 19434797 calls in 10000000438 ns >>> Made 19435733 calls in 10000000439 ns >>> Made 19434499 calls in 10000000438 ns >>> Made 19438482 calls in 10000000438 ns >>> Made 19435604 calls in 10000000142 ns >>> Made 19438551 calls in 10000000438 ns >>> Made 19444550 calls in 10000000290 ns >>> Made 19437580 calls in 10000000290 ns >>> Made 19439429 calls in 10000048142 ns >>> Made 19439493 calls in 10000000438 ns >>> >>> So it seems to be a small improvement. >>> >> Awesome! >> >> I guess this is mostly the effect of simplifying the suspend logic since >> the changes to the cache profile probably wouldn't reveal much in such a >> tight loop. >> >> I will re-run this after acting on your other review comments. BTW what >> device did you run on? > I ran the same test on my Snapdragon 600 board. The results are a little > odd. There is an odd quantization effect that I cannot easily explain > and the results of the v4 patch seem almost too good to be true. > > My results are below but I'd be very interested to see what results you > get with the v4 patch! I ran my test on this msm8960 board I got lying around. In marketing terms (which I honestly don't know off the top of my head) I think it's called a Snapdragon S4 Play. I had to look up Snapdragon 600 to figure out what it is. The 600 is slightly newer but should be an APQ8064 of some kind. Maybe you can try it out on an ARM Ltd. CPU if you have one? > > Latest (branchless approach): > > Made 18736519 calls in 10000000439 ns > Made 19958774 calls in 10000000439 ns > Made 18736500 calls in 10000000587 ns > Made 21703993 calls in 10000000439 ns > Made 18734458 calls in 10000000142 ns > Made 18736175 calls in 10000000439 ns > Made 19961406 calls in 10000000291 ns > Made 19953920 calls in 10000000143 ns > Made 21709619 calls in 10000000290 ns > Made 18734077 calls in 10000000142 ns It's certainly more, but it also seems more variable. I'll reply with raw data from my msm8960 and msm8974 on v4. > v3: > > Made 15971788 calls in 10000000438 ns > Made 14594357 calls in 10000000734 ns > Made 14590951 calls in 10000000735 ns > Made 14595048 calls in 10000000290 ns > Made 14595157 calls in 10000000143 ns > Made 14594117 calls in 10000000142 ns > Made 14597277 calls in 10000000142 ns > Made 14594472 calls in 10000000586 ns > Made 14601292 calls in 10000000587 ns > Made 15968630 calls in 10000000587 ns > > Current: > > Made 14274871 calls in 10000000587 ns > Made 15634136 calls in 10000000587 ns > Made 16453528 calls in 10000000142 ns > Made 14275854 calls in 10000000586 ns > Made 15634128 calls in 10000000438 ns > Made 14277672 calls in 10000000143 ns > Made 14282904 calls in 10000000290 ns > Made 14278673 calls in 10000000142 ns > Made 14276096 calls in 10000000290 ns > Made 14275336 calls in 10000000143 ns -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/