Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756056AbbDOHdz (ORCPT ); Wed, 15 Apr 2015 03:33:55 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:34759 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752896AbbDOHdq (ORCPT ); Wed, 15 Apr 2015 03:33:46 -0400 Date: Wed, 15 Apr 2015 09:33:41 +0200 From: Ingo Molnar To: Jason Low Cc: Linus Torvalds , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Andrew Morton , Oleg Nesterov , Mike Galbraith , Frederic Weisbecker , Mel Gorman , Steven Rostedt , Preeti U Murthy , hideaki.kimura@hp.com, Aswin Chandramouleeswaran , Scott J Norton Subject: Re: [PATCH 2/3] sched, timer: Use atomics for thread_group_cputimer to improve scalability Message-ID: <20150415073340.GB13449@gmail.com> References: <1429052986-9420-1-git-send-email-jason.low2@hp.com> <1429052986-9420-3-git-send-email-jason.low2@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1429052986-9420-3-git-send-email-jason.low2@hp.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1697 Lines: 66 * Jason Low wrote: > While running a database workload, we found a scalability issue with itimers. > > Much of the problem was caused by the thread_group_cputimer spinlock. So I'm fine with the basic principle, but in the hope that maybe posix-cpu-timers will grow similar optimizations in the future, it would help to have the new data type factored out better, not open-coded: > struct thread_group_cputimer { > - struct task_cputime cputime; > + atomic64_t utime; > + atomic64_t stime; > + atomic64_t sum_exec_runtime; > int running; > - raw_spinlock_t lock; > }; So after your changes we still have a separate: struct task_cputime { cputime_t utime; cputime_t stime; unsigned long long sum_exec_runtime; }; Which then weirdly overlaps with a different structure on a different abstraction level: struct thread_group_cputimer { atomic64_t utime; atomic64_t stime; atomic64_t sum_exec_runtime; int running; }; So I think it would be more obvious what's going on if we introduced an atomic task_cputime structure: struct task_cputime_atomic { atomic64_t utime; atomic64_t stime; atomic64_t sum_exec_runtime; }; and put that into 'struct thread_group_cputimer': struct thread_group_cputimer { struct task_cputime_atomic cputime_atomic; int running; }; Maybe even factor out the main update and reading methods into expressively named helper inlines? Thanks, Ingo -- 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/