Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbcL1Ujy (ORCPT ); Wed, 28 Dec 2016 15:39:54 -0500 Received: from mail-dm3nam03on0125.outbound.protection.outlook.com ([104.47.41.125]:12935 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751534AbcL1Ujs (ORCPT ); Wed, 28 Dec 2016 15:39:48 -0500 X-Greylist: delayed 9180 seconds by postgrey-1.27 at vger.kernel.org; Wed, 28 Dec 2016 15:39:47 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=haris.okanovic@ni.com; Subject: Re: [RFC v2] timers: Don't wake ktimersoftd on every tick To: Sebastian Andrzej Siewior References: <20161213214405.28554-1-haris.okanovic@ni.com> <20161223172855.oulixazoxikkkijp@linutronix.de> Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, julia.cartwright@ni.com, gratian.crisan@ni.com From: Haris Okanovic Message-ID: <6febe7d3-9969-7802-72cb-f5d9b297a559@ni.com> Date: Wed, 28 Dec 2016 12:06:42 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161223172855.oulixazoxikkkijp@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [130.164.62.171] X-ClientProxiedBy: CY1PR08CA0028.namprd08.prod.outlook.com (10.163.94.166) To DM5PR04MB0700.namprd04.prod.outlook.com (10.172.187.142) X-MS-Office365-Filtering-Correlation-Id: 900f628c-a6cc-4b45-126d-08d42f4c4962 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR04MB0700; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB0700;3:R8GgxHndlQ3XI8raaok4vh7u2NVeBll344N33p/U9hJWUc1ZrEhuqOAm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riScan:(158342451672863)(166708455590820)(145744241990776)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148);SRVR:DM5PR04MB0700;BCL:0;PCL:0;RULEID:;SRVR:DM5PR04MB0700; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB0700;4:JBeztUyQ5YD3SBZKiVX4VZ7L87zmsM5hqcUTk5uLBu3DzTCX2tEeFJQCWW1Cwq9mxDgAAmgLiQn5FkqbEuDWxAg9ARaQjScbu/AU0pdIt42iw4XFTqGHFJytHVjDZIkGeQRaZI1tkCYqA41p3x590UcQF5QhePAT9hdTPZz7LOjQaMX5wEtRAJBHoljxqd+u12emKdlv0Y8r9wN8trF7M85y2NUBY2pvqUmz/VvmEqjdAtOoA33rHreL73lGrZdIxtIkTrfFVxlT+EqkfLoBqUIMszp8RefFmYf6TugnhjX2H8phJp+gr1L0j/viZIF36JZO0CbjqTaF8f5ZFN/Fmvg2pXlwMV/smT6VhRASXR/dIhfUKn2V7nPWgNtYKHJ969O45oaFTdVLIM6pQf/xTbsNtYOSFHTQtscKFSZ+SLW2Kt4j33MB5pX8Dd01rvS8uZjAEMEJ6ZIPCNprB4w9YZByZLGPQXq06UAYaWIMN/njq46EW65ov33SV8tU6MlKudGV6o25mLlNPYBWf/QnrgC4eAphBuY8ANIHXJ9iVmvXEQMeDcXHkg/r6VNPGgF/wETG4n4X6+rLJhJ3R7Vm5DkleLfavHlG6Pw+S5RLUqUqM52voXuKLrZwlHPEQoYWhTu4MUiRmVxkZyhMV2CcU+wZvl1IeTvUNSjzEk3+Mq8Zz6ph9JWDbpU1AckaZOb8XrmU5Um7vbqjO3N7kYEYwEaS8XxzmPeAwZe+v0EPbIU= X-Forefront-PRVS: 0170DAF08C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(189002)(199003)(377424004)(377454003)(288314003)(24454002)(31686004)(42186005)(25786008)(68736007)(106356001)(105586002)(31696002)(86362001)(6916009)(4001350100001)(189998001)(4001150100001)(6666003)(97736004)(33646002)(65806001)(47776003)(2950100002)(65956001)(66066001)(65826007)(5660300001)(7736002)(305945005)(101416001)(64126003)(50466002)(36756003)(110136003)(6486002)(23676002)(229853002)(83506001)(3846002)(6116002)(38730400001)(2906002)(81166006)(6512006)(6506006)(230700001)(81156014)(76176999)(92566002)(8676002)(54356999)(50986999);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR04MB0700;H:harisdt.amer.corp.natinst.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjA0TUIwNzAwOzIzOlFWZnZMbWFpWDYvTCtSNWdlVm04dGg1TnBL?= =?utf-8?B?OHdERzcxcHlOd0tBcmxqa1RJK25wZGdEZU51TkNpZUdBM3dNWXUwK1hWLzhE?= =?utf-8?B?cnNUL1ljdXdBUkMvdTNxZkhsOU13RWY3aysrSE5VeVpnOWhyZzZ1SElzRm1X?= =?utf-8?B?VWNlcVhpL2JXRHAwQjZHTCtWUXNLZ3crejBHTnpTNS9rK29OU3E2K2xVZmFm?= =?utf-8?B?WE4xOTAvNjM2SjIrM3d0aXBULy9rc3VnRXhIWVFON01LakJGYWthUWpvV0VD?= =?utf-8?B?NEEvWDF2VldydVZ0bEVLQnpEUktDUVNjcFRVZGEzYkdtMThOQlFVcExHTUI0?= =?utf-8?B?QTBjc3FGWUxRMjNYampUM1lvQjkxOEsyVXIvWXhNc2s4aXRmMjV0bllBT1FU?= =?utf-8?B?c1I1Nk56U0V3dG56SVQxQk8vUzFYRW9NWGFaOXpJbE56RHFUMHdCcW5EeVpo?= =?utf-8?B?S1FjaFhJTzFRL1ZLN3NYck1WVlBxSU1XZFl4dkN1QXFlNGZieUlJdTBnS2ww?= =?utf-8?B?NG9FU2NlbmVGa3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QaYNCElkFgQScs7wlGCU+oXxcV1ZqaeEpO9HI8DWS+hLHYJgndPw23v26QLIavVaZxqHZ5GnfXxvMJ8yoxvmP1kx0=;24:rwKeNOCcNp675u3Da/MnkKJlpFmMVwcbOgBO0xHccChLS1BAHC++lQkzDAo0Nkb9BFni/Hi8oGxiyJZLI4ajDxXsM/5YelapuZtwOJpUuvU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB0700;7:5+fgx0tuk4XHri1ZSywsFZP5Z1SvS/U9pDp6ZT2TJXvVIJAeSYuz6eS2kNQ4/LZ5xy88OuvRdu/5IinzKtleTEFnFqM6alF1OfF4k2TWElmnXaTkmsFXHRTvE9TPun5xc+2nK5Q6Y6vuaCvKS2r04JJWFPnDv1M8tHe/+Jg55hvCX1C/szNggcvj94mXAbKFkRw9ZORgapyXRQvGKjqAw7t3Ti+PPsKVGi6VbjmxU13EDwTG1lNqc/X8eOfbV0RUCrJMSQRrJsXJPS50OPlmZjuJxQIxVh77+tesRxXFZpaxrhEPAOtSX2w2+wurpABkZ7uCjZfSn4X6/EJYRLLR1RDXg8/eDrax8UWELTzzp5hNnj9/9euEoIZMw2xF5g6vzEzebUuGDuQ9N79olJfryQLYvHZgMHxQ34bOjkcW6XRly/QnpOV1RcFb5nit5pkAYg+k/+7KJgavFHVkjTpufQ== X-OriginatorOrg: ni.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2016 18:06:45.7333 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB0700 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3668 Lines: 102 On 12/23/2016 11:28 AM, Sebastian Andrzej Siewior wrote: > On 2016-12-13 15:44:05 [-0600], Haris Okanovic wrote: >> Changed the way timers are collected per Julia and Thomas' > > I can only see Julia's response to the initial thread. > I should have been more clear. Thomas commented on irc and recommended Julia's approach. >> recommendation: Expired timers are now collected in interrupt context >> and fired in ktimersoftd to avoid double-walk of `pending_map`. >> >> This is implemented by storing lists of expired timers in timer_base, >> which carries a memory overhead 9*sizeof(pointer) per CPU. The timer >> system uses hlist's which don't have end-node references, making it >> impossible to merge 2 hlist's in constant time. I.e. Merging requires >> walking one list. I also considered switching `vectors` to regular >> list's which don't have this limitations, but that approach has the same >> memory overhead. list_head is bigger than hlist_head by sizeof(pointer) >> and is instantiated 9+ times per CPU as `vectors`. I believe the only >> way to trim overhead is to spend more CPU cycles in interrupt context >> either in list merging (unbounded operation) or the original double-walk >> implementation. Any suggestions/preferences? >> >> As before, a 6h run of cyclictest without CPU affinity shows decrease in >> 22-70us latency range. > what does this mean? Your cyclictest runs on a random CPU with one thread > only? > Yes. My point is that cyclictest only shows a significant difference (before and after this change) when `-S` is not used. >> No change in max jitter. > Does this mean your average latency went down 20-70us and your max is > the same? > Yes. Average latency (20-70us range) goes down in a single-threaded run of cyclictest. Max jitter stays the same in both single and multi-thread runs. >> No change when `-S` is >> used. > > -S gives you one thread per core, makes sure it stays on that core and > uses clock_nanosleep(). > > clock_nanosleep() should be used no matter what. > > >> [Before/after traces] >> >> ftp://ftp.ni.com/outgoing/tp02-timer-peek-traces.tgz >> (Email me if link dies. Server periodically purges old files.) >> >> [Hardware/software/config] >> >> NI cRIO-9033 >> 2 core Intel Atom CPU >> >> Kernel 4.8.6-rt5 >> CONFIG_HZ_PERIODIC=y >> >> [Outstanding concerns/issues/questions] >> >> I'm relatively new to the timer subsystem, so please feel free to poke >> as many holes as possible in this change. A few things that concern me >> at the moment are: >> >> Can jiffies change while one or more cpus is inside tick_sched_timer(), >> in interrupt context? I'm copying jiffies to a local variable in >> find_expired_timers() to ensure it doesn't run unbounded, but I'm not >> sure if that's necessary. > > It could change. Only the house keeping does update jiffies in > tick_sched_do_timer(). > >> Any special considerations for testing NO_HZ builds? (Other than letting >> it run idle for a while) >> >> timers_dead_cpu() presently asserts no timer callback is actively >> running, which suggests that timers must be canceled prior to disabling >> CPUs; otherwise, there's a race between active timers and hotplug >> which can crash the whole kernel. Is this a safe assumption to make and >> are there any special considerations for CPU hotplug testing? > > timers_dead_cpu() and hrtimers_dead_cpu() migrate timer away. At that > point the CPU should be down already so a timer can't run on that CPU. > >> Other tests/performance benchmark I should run? >> >> Source: https://github.com/harisokanovic/linux/tree/dev/hokanovi/timer-peek-v2 >> >> Thanks, >> Haris > > Sebastian > -- Haris