Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755486AbcCPTVv (ORCPT ); Wed, 16 Mar 2016 15:21:51 -0400 Received: from mail-bl2on0114.outbound.protection.outlook.com ([65.55.169.114]:12640 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753137AbcCPTVt (ORCPT ); Wed, 16 Mar 2016 15:21:49 -0400 Authentication-Results: linux.com; dkim=none (message not signed) header.d=none;linux.com; dmarc=none action=none header.from=hpe.com; Message-ID: <56E9B219.7090500@hpe.com> Date: Wed, 16 Mar 2016 15:20:57 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Christoph Lameter CC: Tejun Heo , Dave Chinner , , , Ingo Molnar , Peter Zijlstra , Scott J Norton , Douglas Hatch Subject: Re: [RFC PATCH 1/2] percpu_counter: Allow falling back to global counter on large system References: <1457146299-1601-1-git-send-email-Waiman.Long@hpe.com> <1457146299-1601-2-git-send-email-Waiman.Long@hpe.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [72.71.243.172] X-ClientProxiedBy: BY1PR14CA0025.namprd14.prod.outlook.com (25.161.91.35) To TU4PR84MB0317.NAMPRD84.PROD.OUTLOOK.COM (25.162.186.27) X-MS-Office365-Filtering-Correlation-Id: a01220bc-0edd-486d-eb6b-08d34dd03750 X-Microsoft-Exchange-Diagnostics: 1;TU4PR84MB0317;2:OTj6LV5mmFwUKSpp7rGgXM0AwdLhJhzU5nMh+X+Q8BSQ94imzR0AG/TLOFMrYepM4Spb5YyIQ+0LEWvieG963Fy1YZ37Y6/m5P1F/HmYpD8aJHwV0soUKHBorQEICK4u6m7NHrk5y/OhtT+xDNDZtpSIRW+4ZHiBq2BCG7DLNWGx1NfrrFKOOS6ro2JJks8e;3:tUHL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lvpE5ip32Xx+Mvh6/S3WgIjSxsBPOLXEBpWdOTcpsxiHlWTBsdQr8hmlHGUhL4DOidcJ+jQurBjIA+BaCk6Qjt4T3pTE1nETNthmrPTr/taL+FeczObb+HkBUFIcYf69bgnE55Rv9KwU/LHIdJ4irDg8Fzs9eEZbTG6OajjDTioIpnNnTlLrxjd X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:TU4PR84MB0317;BCL:0;PCL:0;RULEID:;SRVR:TU4PR84MB0317; X-Forefront-PRVS: 08831F51DC X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(24454002)(479174004)(377454003)(189998001)(110136002)(66066001)(2950100001)(50466002)(5004730100002)(2906002)(47776003)(4326007)(4001350100001)(5008740100001)(86362001)(36756003)(83506001)(33656002)(42186005)(76176999)(65816999)(87266999)(54356999)(50986999)(586003)(3846002)(6116002)(81166005)(230700001)(77096005)(117156001)(64126003)(92566002)(1096002)(23756003)(80316001)(7059030)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:TU4PR84MB0317;H:[192.168.142.137];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;TU4PR84MB0317;23:olz/+9jVS55LCa+IqHMl/HaIJilCMcoMVEujwva?= =?iso-8859-1?Q?hpzPw/NFj091a2CjVKn+Q0OqKvDIhWYB0lsRJQWmvubdtq4QFaAcXzQrdQ?= =?iso-8859-1?Q?unbE4PFPoTShgeB2D2vd2FchOJJpTWL7wfPNpNDcLKc3ORapJg2WIUxwN1?= =?iso-8859-1?Q?P4cdQCkbtraYpBY8K+jl5WrT+8SzBVQ6g02Mhgtts6ejZLqLVOFlBeWp91?= =?iso-8859-1?Q?PdL4POey93mYHIxbxUan/xbUk8PQUmUJd3QpKw+4VRg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oft-Exchange-Diagnostics: 1;TU4PR84MB0317;5:78UxDxSQ+MrWoB0BqvUf25D7D9jW7tnienZtAL4PSwS73xJpXanL5LhgXSOs7ouE6vZv6aI5LkabsdvOSPYakp+cFFmbvkzsiSmfk2vZ5NRdTBnP72q9YUI3UOxCVYC7MKSfYxI2WD3w7rAIomQNBg==;24:DZ6zvgzMEzmDWsDF//IURcmkYL4N1LseNB+LcGttpzwfYLCl3geC4jFAXT/6OV7Z2Ze5PhOux12WP17qlKg7wjUG3g/Hp0Wkrpa9C6/x3w8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2016 19:21:29.4232 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR84MB0317 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1798 Lines: 39 On 03/07/2016 01:24 PM, Christoph Lameter wrote: > On Fri, 4 Mar 2016, Waiman Long wrote: > >> This patch provides a mechanism to selectively degenerate per-cpu >> counters to global counters at per-cpu counter initialization time. The >> following new API is added: >> >> percpu_counter_set_limit(struct percpu_counter *fbc, >> u32 percpu_limit) >> >> The function should be called after percpu_counter_set(). It will >> compare the total limit (nr_cpu * percpu_limit) against the current >> counter value. If the limit is not smaller, it will disable per-cpu >> counter and use only the global counter instead. At run time, when >> the counter value grows past the total limit, per-cpu counter will >> be enabled again. > Hmmm... That is requiring manual setting of a limit. Would it not be > possible to completely automatize the switch over? F.e. one could > keep a cpumask of processors that use the per cpu counters. > > Then in the fastpath if the current cpu is a member increment the per cpu > counter. If not do the spinlock thing. If there is contention add the > cpu to the cpumask and use the per cpu counters. Thus automatically > scaling for the processors on which frequent increments are operating. > > Then regularly (once per minute or so) degenerate the counter by folding > the per cpu diffs into the global count and zapping the cpumask. > > If the cpumask is empty you can use the global count. Otherwise you just > need to add up the counters of the cpus set in the cpumask. > I have modified the patch to try that out. However, that doesn't yield that much of improvement in term of performance and it slows down the percpu fast path a bit. So I am going to focus on my existing patch first and think about that later. Cheers, Longman