From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49940 invoked by alias); 18 Aug 2017 12:13:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 44840 invoked by uid 89); 18 Aug 2017 12:13:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=overcome X-HELO: mail-qk0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aWyzlbT+plTEsMTx4pGUuhGcrFmzzhWcRGGzwiOTqjU=; b=pGPPBGs0E7X7kZElB0rdzQrUD+BheagFH8X490rjBybiPA1gC02I//ubrW7NhOg8oz QuHWlkP6kMs1GAyTXKH3bOCCcd5YUSmLfYBvnIvHQoiMh++Sshd1a2pPfumM5V4UttG8 9/x4sfkJ0OS2/Xsyd1UT05kvQaMfxST3Bk4IJYjxV6dKRot4+XVFZwN1QQW6YNf2n+/d WhWfzRNcVXjW0CpJ7JNHSj5nRqdK7jmzieoHtPTqrY5JpGlCTyqlWdJlL8rrxpBSeVgR hyPfy+W+t3wbqNwTNjW/f0j2FCvvvkJjR3F/QRDvTyyS0VRymas0S11ccvqHEJir7mQY 3Phg== X-Gm-Message-State: AHYfb5j6fBIQVwGqBJy2dnvaFH3f98SpWN12aY63exLIqntCXuvJ7MDO U1tLhwitWAzAIIlIvgrHQg== X-Received: by 10.55.155.148 with SMTP id d142mr2780103qke.271.1503058393904; Fri, 18 Aug 2017 05:13:13 -0700 (PDT) Subject: Re: [PATCH] powerpc: Use aligned stores in memset To: libc-alpha@sourceware.org References: <1503033107-20047-1-git-send-email-raji@linux.vnet.ibm.com> From: Adhemerval Zanella Message-ID: Date: Fri, 18 Aug 2017 12:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2017-08/txt/msg00856.txt.bz2 On 18/08/2017 06:10, Florian Weimer wrote: > On 08/18/2017 08:51 AM, Rajalakshmi Srinivasaraghavan wrote: >> >> >> On 08/18/2017 11:51 AM, Florian Weimer wrote: >>> On 08/18/2017 07:11 AM, Rajalakshmi Srinivasaraghavan wrote: >>>> * sysdeps/powerpc/powerpc64/power8/memset.S: Store byte by byte >>>> for unaligned inputs if size is less than 8. >>> >>> This makes me rather nervous. powerpc64le was supposed to have >>> reasonable efficient unaligned loads and stores. GCC happily generates >>> them, too. >> >> This is meant ONLY for caching inhibited accesses. Caching Inhibited >> accesses are required to be Guarded and properly aligned. > > The intent is to support memset for such memory regions, right? This > change is insufficient. You have to fix GCC as well because it will > inline memset of unaligned pointers, like this: > > typedef long __attribute__ ((aligned(1))) long_unaligned; > > void > clear (long_unaligned *p) > { > memset (p, 0, sizeof (*p)); > } > > clear: > li 9,0 > std 9,0(3) > blr > > That's why I think your change is not useful in isolation. POWER8 does have fast unaligned access memory and in fact unaligned access could be used to provide a faster memcpy/memmove implementation (I created one that I never sent upstream some time ago [1]). Unaligned accesses are used extensively in some optimized str* implementation I created for POWER8. It also allows GCC to use unaligned access for builtin mem* operation without issue on *most* of the cases. The problem is memset/memcpy/memmove *specifically* are used in some userland drivers for DMA (if I recall correctly for some XORG drivers) and for this specific user cases using unaligned access, specially vector ones, will case the kernel to trap on *every* unaligned instruction leading to abysmal performance. That's why I pushed 87868c2418fb74357757e3b739ce5b76b17a8929 to fix this very issue for POWER7 memcpy. We already discussed this same issue some time ago [2] to try overcome this limitation. I think ideally the drivers that rely on aligned mem* operations should we its own mem* operations (similar to how dpdk does [3]). [1] https://github.com/zatrazz/glibc/commits/memopt-power8 [2] https://sourceware.org/ml/libc-alpha/2015-01/msg00130.html [3] http://dpdk.org/browse/dpdk/tree/lib/librte_eal/common/include/arch/ppc_64/rte_memcpy.h