Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758780AbcDHRdL (ORCPT ); Fri, 8 Apr 2016 13:33:11 -0400 Received: from mail-bl2on0113.outbound.protection.outlook.com ([65.55.169.113]:24032 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754361AbcDHRdI (ORCPT ); Fri, 8 Apr 2016 13:33:08 -0400 Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=hpe.com; Message-ID: <5707EB44.9020703@hpe.com> Date: Fri, 8 Apr 2016 13:32:52 -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: Tejun Heo CC: "Theodore Ts'o" , Andreas Dilger , Christoph Lameter , , , Scott J Norton , Douglas Hatch , Toshimitsu Kani Subject: Re: [PATCH v2 2/4] percpu_stats: Enable 64-bit counts in 32-bit architectures References: <1460132182-11690-1-git-send-email-Waiman.Long@hpe.com> <1460132182-11690-3-git-send-email-Waiman.Long@hpe.com> <20160408164747.GM24661@htj.duckdns.org> In-Reply-To: <20160408164747.GM24661@htj.duckdns.org> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [72.71.243.129] X-ClientProxiedBy: SN1PR17CA0033.namprd17.prod.outlook.com (10.169.33.171) To AT5PR84MB0307.NAMPRD84.PROD.OUTLOOK.COM (10.162.138.29) X-MS-Office365-Filtering-Correlation-Id: 1801816c-41eb-469a-effe-08d35fd3d69f X-Microsoft-Exchange-Diagnostics: 1;AT5PR84MB0307;2:vbIANxrmSfXE4sP68XtleODVLVhq+MeZgVQbr3j0HCGntp7P/gpqXGwFhYp3EcieE9E6r/GiqBSvFBR/6HK1AgufxMTsqukgq6RYo0BCpN7h+16EZJuJ9WofvYIuL6n0Qt54tqTUpoW/sHG6oKeIq92dqzXjkJ1YVUYq6KKNFxxI2zSlNMu+M/RhhPJfpv/0;3:arcGO2uGgmp0UjR2wrTJriw2qaRL0HyCrfcLsV3VO1pJeEIWivFT/inkof1Sb0t5L1ZLPDA4tJ8XtRC3cmJsqmfQrf5eKrhTAY3z0RP0scCzYxllNVhKxNxvQ2amNWpU X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AT5PR84MB0307; X-Microsoft-Exchange-Diagnostics: 1;AT5PR84MB0307;25:opsJn/wqmCFemW505grSrG0iwtAq10BdZ1BG4fdD6N70mUhNVT2vLBvhMW9J+osl0gc5g7Gp6kxLA5Dgj/DTQJ6ePtL6IUB5gDO4eNLWCSFPGNucjZMphrOgloxwTxu1f4iWdqSPkAvYoAHGpmj2d43Ax8c5buxVnxkdZigayTkr8U2jdHP/ue6Dv+IAQg6khkt1V3i5Wz8fa8nAd7fYd53dp4xxEr6OHtk4FJ95hxMq3N4h4HM7ThAITbg8cLpEeUViNDNzJ586Ucj9/Xk3/3BYpJ8X+pkG3hPhz6dvrtth8qKz2x0tP0oks+/dPL+RcCao/ywNeRfE68LpqI87ankErWgSIKG4u7gKzcIaoPOTYjNdn4gObsu0T1uxj9mCQRj+cMtNbTfdHB83zrH8MJ6hccSdD0Gfy86rYokwEq3gy+9jHicXxoFCM9GOWOiQsRd4LhFx5JI34EuXlk8YmFBqnIqpbSwYr7P3+qD8AZqO6dWXvJkreE8oH1hykprEZ9pBTecWCpRIQdts7eSMCl2nWfzye0S/pMGTouABtI7uixEmBTsH/qvvGnZ33PgP5+bdD9IFa1i41iDegJzulujAlwPcMxJNixyyxn242S3Ak9UfQmlqDAQvQQbDIw0bqsY5jLCBe5z4yc/jEiZlhA== X-LD-Processed: 105b2061-b669-4b31-92ac-24d304d195dc,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;AT5PR84MB0307;20:Jm9SbQSOthHh1B0zcrTQSluQRkksEm4Yi5bcUMLbDfsvwgSUOE/udKdrlGpa9IZeIw6TbkCvLjONPlPFGxhPwK3gW5qAsTYPqtkGUj002nZmjywZfrqGHu8Qxio6wz01IPtz0RShg3bsxCfQSY9jTsV2GXTxg0SvYCrNXkgC1uucvspJk+iitqsV+D22gIHPudS7hh5VOonRg3mMEsrK10amrm9s5ELFYQkWE4MI8eKDHTWdsVWLb2UShMeNdoqd8/repenFIaC1Am8TR+K3UieiidP83eTl8DLg8nGAdY1S77yUvAI5102tWooY26wUsqK3QN8S7DBYI1SDNAr4hA==;4:bRBR9KJIv7bSntNH8VDU/ZGDawm2B4nhwmgMxrReqVEzb0KAcatRZ9d0OucYSBA8JKjPLrDDJen+ERLW6yX/s6yOnBdSua6L2h+dgt8auEH/OlVdJrrJExW1LdHbhvavx1egKfaflNWW0pmtRczEJfWGuFP9c9udcXOUhmO+RtMPjRFjFJNN79VZUxQbODJqFeLZD6QkwVA1u4RltGqTd0slZciFzUHXK5DpXyIE/jRdhNJ36F68b1ArxiD8SG7oGdem8L75LbrFWLO1MOBaoV1Bw+1eiNZjGzBQ4/CODi9E5HbauU9hlqlwwoKbDgLvMBR/BlF765FWI97c8ZTvoGIHfVvm0DeWnaWvJ2RGmIULgbhvbs1VZNt0d8hGTHJ4ZcW0eiAAJHAe9bjexckoOg== 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)(10201501046)(3002001)(6055026);SRVR:AT5PR84MB0307;BCL:0;PCL:0;RULEID:;SRVR:AT5PR84MB0307; X-Forefront-PRVS: 0906E83A25 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(24454002)(76104003)(377454003)(23756003)(50986999)(50466002)(117156001)(59896002)(86362001)(65816999)(80316001)(87266999)(54356999)(586003)(76176999)(66066001)(65956001)(47776003)(81166005)(64126003)(83506001)(5008740100001)(6116002)(3846002)(77096005)(1096002)(5004730100002)(4326007)(4001350100001)(42186005)(189998001)(110136002)(36756003)(2906002)(92566002)(33656002)(230700001)(2950100001);DIR:OUT;SFP:1102;SCL:1;SRVR:AT5PR84MB0307;H:[192.168.142.153];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;AT5PR84MB0307;23:axQIU8vfPPbT+USX7X9jXenhg4xLC/XQFV9isVf?= =?iso-8859-1?Q?CXxWZ+WmfvBp54s9XiWFppuF46X2d0HDsoM/Mg7Ub16InqliPHnbcuRyyP?= =?iso-8859-1?Q?WWgSbS0MC/Sy7ggxv8CifV8M8oAetz6qx1H8MAcKNTKx4KcA4jNO78DSQ1?= =?iso-8859-1?Q?jnKPSRRBcxC38GKoXIV7Z9WzhSlZeYZzOzSNUuMDbYYrgDrTPod9oCnCjm?= =?iso-8859-1?Q?JBtuAC+lSeOqS51F+E0bau66lDr+MC9BimY4UA8MTiQEkFYNbJ+DNIXIax?= =?iso-8859-1?Q?jnM8L2z2IbFqYkuUPI86BfKJpBSjzMZHBE+b42uC8vAXgbgsoEEoEd3xks?= =?iso-8859-1?Q?J2mhSfeiyDyDthgfubLG9m1pe77WlHCc4ldUnoq1MrobbTDsgh78CC4dwn?= =?iso-8859-1?Q?Tc5UKx60UxX6dPFEjkSLfgGuo9j9qi0l+xjlbiJUvaJ3Cq4Ta8x1rtlym6?= =?iso-8859-1?Q?6Ab76ekgTwT5pAAp8rZ03Zi54XQsdP1lghA6HjVxnM466T7MTy5vcw+6pf?= =?iso-8859-1?Q?IfLluUB0qluKq/qA61D0C7FJB/N4fanMG9u5XQUN5hJMSVr3xODrEEcoSE?= =?iso-8859-1?Q?8+ixXfPREF65dqp7X8m37zhUxQdhXCk6BtoLKEkq5+DeaMT4dIgRDR1I6o?= =?iso-8859-1?Q?MerpoIJBa1G1laqQYsxjRlLOHyppw6KwXxMyirMlTMOcjFFzCVcpCM/HY+?= =?iso-8859-1?Q?Uppznvf6Mqd+gxbSj89McL042L+q6iESq1HnS/hupwvA+QTXZQ1VnRFv+3?= =?iso-8859-1?Q?pUHTFy3Kd9z32OZIbYQiO84USlHYaiOWrdAex/wy9BixdLy9ODGh/qDeRJ?= =?iso-8859-1?Q?8a6vAXCKGEe/d0nqe2hUeNbchag0+5pqMs/MYWFuEf7+r+10tGEBm0p3Xp?= =?iso-8859-1?Q?Usz+QNXtmhQXyt53EI9IjMrpfPSsokVSq+FCK4FLHT2XNQuiJ99uVVh/M8?= =?iso-8859-1?Q?rQfXqAx6qWc9ElOdR/BZjVmTSdij3MxJug4vrcTMcoMSgacGKHhxp0F+Wf?= =?iso-8859-1?Q?ejglfhiOTtl5tsLp86mLvTWFcs0wC5MnVAg5XrZ8HW0dyMkCTxqgjZ4X7Y?= =?iso-8859-1?Q?qzSzw7e+kQ55FFJOA3CSWcB6qAVdyICr/jmxn9mZYu3UQhiKt0zt9ZZhZd?= =?iso-8859-1?Q?+94Se?= X-Microsoft-Exchange-Diagnostics: 1;AT5PR84MB0307;5:UMCa90QAARiYu9hHPOkqjZr96jkqFaIuHLdixQP3GcUbesX41Zi0yGeKMBr+XQ1KcDaS+MX7/sR4EhWg8+n4YihEdudCq524SiBH8I998lzj/dIPzvXBlDrqu5vXKY8D0fmC9FuQ3xUfBXytZhH7fQ==;24:qDB/KDP9vAmSEIen+D4IC5VZnHTAJr50S7U+j7R/dck5nq2JXCwkM6ZmPtg/2Bomg9f0qKdJRRqfM/veQ0vt0b4SzfnvsPREcgAwdIQRB0s= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2016 17:33:02.3228 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AT5PR84MB0307 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2070 Lines: 55 On 04/08/2016 12:47 PM, Tejun Heo wrote: > Hello, Waiman. > > On Fri, Apr 08, 2016 at 12:16:20PM -0400, Waiman Long wrote: >> +/** >> + * __percpu_stats_add - add given count to percpu value >> + * @pcs : Pointer to percpu_stats structure >> + * @stat: The statistics count that needs to be updated >> + * @cnt: The value to be added to the statistics count >> + */ >> +void __percpu_stats_add(struct percpu_stats *pcs, int stat, int cnt) >> +{ >> + /* >> + * u64_stats_update_begin/u64_stats_update_end alone are not safe >> + * against recursive add on the same CPU caused by interrupt. >> + * So we need to set the PCPU_STAT_INTSAFE flag if this is required. >> + */ >> + if (IS_STATS64(pcs)) { >> + uint64_t *pstats64; >> + unsigned long flags; >> + >> + pstats64 = get_cpu_ptr(pcs->stats64); >> + if (pcs->flags& PCPU_STAT_INTSAFE) >> + local_irq_save(flags); >> + >> + u64_stats_update_begin(&pcs->sync); >> + pstats64[stat] += cnt; >> + u64_stats_update_end(&pcs->sync); >> + >> + if (pcs->flags& PCPU_STAT_INTSAFE) >> + local_irq_restore(flags); >> + >> + put_cpu_ptr(pcs->stats64); >> + } >> +} > Heh, that's a handful, and, right, u64_stats needs separate irq > protection. I'm not sure. If we have to do the above, it's likely > that it'll perform worse than percpu_counter on 32bits. On 64bits, > percpu_counter would incur extra preempt_disable/enable() operations > but that comes from it not using this_cpu_add_return(). I wonder > whether it'd be better to either use percpu_counter instead or if > necessary extend it to handle multiple counters. What do you think? > > Thanks. > Yes, I think it will be more efficient to use percpu_counter in this case. The preempt_disable/enable() calls are pretty cheap. Once in a while, you need to take the lock and update the global count. How about I change the 2nd patch to use percpu_counter internally when 64-bit counts are needed in 32-bit archs, but use the regular percpu counts on 64-bit archs? If you are OK with that, I can update the patch accordingly. Cheers, Longman