Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753680AbdDLOAx (ORCPT ); Wed, 12 Apr 2017 10:00:53 -0400 Received: from mail-by2nam03on0085.outbound.protection.outlook.com ([104.47.42.85]:44000 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752379AbdDLOAr (ORCPT ); Wed, 12 Apr 2017 10:00:47 -0400 From: "Chalamarla, Tirumalesh" To: Imran Khan , Ganesh Mahendran , Catalin Marinas CC: "open list:ARM/QUALCOMM SUPPORT" , open list , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] Revert "arm64: Increase the max granular size" Thread-Topic: [PATCH] Revert "arm64: Increase the max granular size" Thread-Index: AQHRf2q07H5kbo3Bx0+pHW/tbsCLGJ9fP6wAgATroICCViMSRIAAkAuAgACp54CACA/OAIAAHgwA Date: Wed, 12 Apr 2017 14:00:43 +0000 Message-ID: <725F073F-025B-48B9-9935-24EFEBF2B7DC@caviumnetworks.com> References: <1458120743-12145-1-git-send-email-opensource.ganesh@gmail.com> <20160321171403.GE25466@e104818-lin.cambridge.arm.com> <10fef112-37f1-0a1b-b5af-435acd032f01@codeaurora.org> <4525901c-45d4-6bd8-eec6-ae92977f16d1@codeaurora.org> <20170406155825.GA7705@e104818-lin.cambridge.arm.com> <08fa98de-760b-15bc-5220-fa449b08c118@codeaurora.org> In-Reply-To: <08fa98de-760b-15bc-5220-fa449b08c118@codeaurora.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/f.20.0.170309 authentication-results: codeaurora.org; dkim=none (message not signed) header.d=none;codeaurora.org; dmarc=none action=none header.from=cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2601:641:c080:3581:1d2f:7444:801:a39e] x-microsoft-exchange-diagnostics: 1;BLUPR0701MB1059;7:KJzZgBfCTRH+t757n8N4ik4SpQ2POLmj4LXMfyeVv2JkGGTEtKGJAZSGwcyhG6GR3+gWO81nk3P9f26qEMD4H7tqlabx2/ZfrElL1zP9Lk9lfibsQxs2mxA+lGynn12/T0aRPrRKyiM5hXDAgBHA255CCe/EBMOWg5f4/yEG4d9F6e4riFoYXqFb0j+lRvISe2hhLwsf2lZQ2xKfs2l8uVIRq2/F0U2a4UwseFESrKAX5Pk4d616Ctn/tXCWdT/LD9zLPEiQQ5xEaaAA++XCC0ac6kthjWIHJapuVK19URyqc694g1NxdBj8NZWQLDfTFfcWDci8kbX95QXF0AhuBQ== x-ms-office365-filtering-correlation-id: 5de5b9cb-5d97-400a-14b2-08d481ac4fc2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081);SRVR:BLUPR0701MB1059; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(228788266533470)(258649278758335)(211936372134217); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148);SRVR:BLUPR0701MB1059;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1059; x-forefront-prvs: 027578BB13 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39410400002)(39850400002)(39400400002)(39840400002)(39450400003)(377424004)(24454002)(377454003)(8676002)(81166006)(8936002)(122556002)(4001350100001)(189998001)(36756003)(6436002)(6486002)(39060400002)(77096006)(4326008)(6506006)(38730400002)(3660700001)(83506001)(2906002)(6246003)(53936002)(83716003)(82746002)(86362001)(2950100002)(3280700002)(93886004)(50986999)(2900100001)(33656002)(1720100001)(305945005)(5660300001)(7736002)(966004)(6512007)(6306002)(9686003)(53546009)(99286003)(229853002)(54356999)(54906002)(25786009)(76176999)(102836003)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1059;H:BLUPR0701MB1060.namprd07.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <307D8BE93EACA34998A65E48232DDD49@namprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2017 14:00:43.5777 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1059 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v3CE17Ku016927 Content-Length: 5937 Lines: 135 On 4/11/17, 10:13 PM, "linux-arm-kernel on behalf of Imran Khan" wrote: On 4/7/2017 7:36 AM, Ganesh Mahendran wrote: > 2017-04-06 23:58 GMT+08:00 Catalin Marinas : >> On Thu, Apr 06, 2017 at 12:52:13PM +0530, Imran Khan wrote: >>> On 4/5/2017 10:13 AM, Imran Khan wrote: >>>>> We may have to revisit this logic and consider L1_CACHE_BYTES the >>>>> _minimum_ of cache line sizes in arm64 systems supported by the kernel. >>>>> Do you have any benchmarks on Cavium boards that would show significant >>>>> degradation with 64-byte L1_CACHE_BYTES vs 128? >>>>> >>>>> For non-coherent DMA, the simplest is to make ARCH_DMA_MINALIGN the >>>>> _maximum_ of the supported systems: >>>>> >>>>> diff --git a/arch/arm64/include/asm/cache.h b/arch/arm64/include/asm/cache.h >>>>> index 5082b30bc2c0..4b5d7b27edaf 100644 >>>>> --- a/arch/arm64/include/asm/cache.h >>>>> +++ b/arch/arm64/include/asm/cache.h >>>>> @@ -18,17 +18,17 @@ >>>>> >>>>> #include >>>>> >>>>> -#define L1_CACHE_SHIFT 7 >>>>> +#define L1_CACHE_SHIFT 6 >>>>> #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) >>>>> >>>>> /* >>>>> * Memory returned by kmalloc() may be used for DMA, so we must make >>>>> - * sure that all such allocations are cache aligned. Otherwise, >>>>> - * unrelated code may cause parts of the buffer to be read into the >>>>> - * cache before the transfer is done, causing old data to be seen by >>>>> - * the CPU. >>>>> + * sure that all such allocations are aligned to the maximum *known* >>>>> + * cache line size on ARMv8 systems. Otherwise, unrelated code may cause >>>>> + * parts of the buffer to be read into the cache before the transfer is >>>>> + * done, causing old data to be seen by the CPU. >>>>> */ >>>>> -#define ARCH_DMA_MINALIGN L1_CACHE_BYTES >>>>> +#define ARCH_DMA_MINALIGN (128) >>>>> >>>>> #ifndef __ASSEMBLY__ >>>>> >>>>> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c >>>>> index 392c67eb9fa6..30bafca1aebf 100644 >>>>> --- a/arch/arm64/kernel/cpufeature.c >>>>> +++ b/arch/arm64/kernel/cpufeature.c >>>>> @@ -976,9 +976,9 @@ void __init setup_cpu_features(void) >>>>> if (!cwg) >>>>> pr_warn("No Cache Writeback Granule information, assuming >>>>> cache line size %d\n", >>>>> cls); >>>>> - if (L1_CACHE_BYTES < cls) >>>>> - pr_warn("L1_CACHE_BYTES smaller than the Cache Writeback Granule (%d < %d)\n", >>>>> - L1_CACHE_BYTES, cls); >>>>> + if (ARCH_DMA_MINALIGN < cls) >>>>> + pr_warn("ARCH_DMA_MINALIGN smaller than the Cache Writeback Granule (%d < %d)\n", >>>>> + ARCH_DMA_MINALIGN, cls); >>>>> } >>>>> >>>>> static bool __maybe_unused >>>> >>>> This change was discussed at: [1] but was not concluded as apparently no one >>>> came back with test report and numbers. After including this change in our >>>> local kernel we are seeing significant throughput improvement. For example with: >>>> >>>> iperf -c 192.168.1.181 -i 1 -w 128K -t 60 >>>> >>>> The average throughput is improving by about 30% (230Mbps from 180Mbps). >>>> Could you please let us know if this change can be included in upstream kernel. >>>> >>>> [1]: https://groups.google.com/forum/#!topic/linux.kernel/P40yDB90ePs >>> >>> Could you please provide some feedback about the above mentioned query ? >> >> Do you have an explanation on the performance variation when >> L1_CACHE_BYTES is changed? We'd need to understand how the network stack >> is affected by L1_CACHE_BYTES, in which context it uses it (is it for >> non-coherent DMA?). > > network stack use SKB_DATA_ALIGN to align. > --- > #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ > ~(SMP_CACHE_BYTES - 1)) > > #define SMP_CACHE_BYTES L1_CACHE_BYTES > --- > I think this is the reason of performance regression. > Yes this is the reason for performance regression. Due to increases L1 cache alignment the object is coming from next kmalloc slab and skb->truesize is changing from 2304 bytes to 4352 bytes. This in turn increases sk_wmem_alloc which causes queuing of less send buffers. We tried different benchmarks and found none which really affects with Cache line change. If there is no correctness issue, I think we are fine with reverting the patch. Though I still think it is beneficiary to do some more investigation for the perf loss, who knows 32 bit align or no align might Give even more perf benefit. Thanks, Tirumalesh. >> >> The Cavium guys haven't shown any numbers (IIUC) to back the >> L1_CACHE_BYTES performance improvement but I would not revert the >> original commit since ARCH_DMA_MINALIGN definitely needs to cover the >> maximum available cache line size, which is 128 for them. > > how about define L1_CACHE_SHIFT like below: > --- > #ifdef CONFIG_ARM64_L1_CACHE_SHIFT > #define L1_CACHE_SHIFT CONFIG_ARM64_L1_CACHE_SHIFT > #else > #define L1_CACHE_SHIFT 7 > endif > --- > > Thanks > >> >> -- >> Catalin -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a\nmember of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel