Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp604228imm; Thu, 6 Sep 2018 07:27:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWf0/i1WE2Rr37pJ/WHiLIlwgnFqG9IQVmEI2aA+HGtx27VczZEpGi66STaV6TeUUwTQ+E X-Received: by 2002:a62:868b:: with SMTP id x133-v6mr3115724pfd.252.1536244030915; Thu, 06 Sep 2018 07:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536244030; cv=none; d=google.com; s=arc-20160816; b=mzIniyv8DgsagPaOaAvR1VOQbFKZm7+MvXr6XMNabZ0EyNWN2SkFpwUA/R/0ZaizbD 9bKbNM0e40GRtXLLehC0thuKotb14bI1YNoiXyYwNVHmGr1KxvAgkHOdofh165Bff2Rv tV5iTkbDgmXkK44f6xON+27JQ74R/0wxJIi4PbMAOub79lWqo22gI5GPvtfkgxGpLdiF Ek0zcsfO3eUXO6jhmw/3yr0jKji2op1VG5E7u4/EmnVZbA60K9DLtCQbluvAZBBamomI BRlvcnGP5yWbaRI7wFRVkzg37RSHZ0upjC2vTy0MQHwqVeFdrs3kfdjQRTr8QukEYOG0 rMIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ctR1dcDAHtbRU+PPJ3lprKnXzJPh4hAEr4eUNfmeKvk=; b=r3u76trhdzn0yscddE9FCIrUAx5uNtNJfl3LNrUU5U4meb8fs7aQ+2hiFDgOsSMLTO VQY8XRhHpTZ/Ccw8ZF5v/62sUqEM6H+AWZpH9PhPKyW5vJNSOHvKhvnE3mWbOGazXdwQ oeLi1aBC6dD8nX7T3arkmZLJnHpCLAtIUUYRuCVLvh86DmmngB7nvbMAzjdQ/gDlJwdP e70CK7x/s6xpt/09zKe6s5jULeG0fhgYAy1z5V0eI/XRVwOvq0nPRTH95ydC9RpwmUwr TQmnE0ULq9Ga+92i5sXkY9aTeoxjnd7Qk+FWls/0s9Yok3IeVT61c+EH6ewLjJjicZNE O4zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n28-v6si5367475pfg.127.2018.09.06.07.26.51; Thu, 06 Sep 2018 07:27:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729875AbeIFTBD (ORCPT + 99 others); Thu, 6 Sep 2018 15:01:03 -0400 Received: from mail-qt0-f179.google.com ([209.85.216.179]:39165 "EHLO mail-qt0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbeIFTBD (ORCPT ); Thu, 6 Sep 2018 15:01:03 -0400 Received: by mail-qt0-f179.google.com with SMTP id o15-v6so12431675qtk.6; Thu, 06 Sep 2018 07:25:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ctR1dcDAHtbRU+PPJ3lprKnXzJPh4hAEr4eUNfmeKvk=; b=Qy6eoXqqmrTbwZ/7IrSixuTBx3F72oRghJ97Y0RWkitgeRIRhoFuc3+lc+wOjTRxXZ wx61FbpeX7DgHGzV9Kf3f7WSmErTr8wJvOyXVZSc/VMAr3RvzHbbupsMQ0TNLxbt6gSX RXj6izccFqoFtpbarYwGyYwo+Kj1R5SsZKoAPccqJLVqhjv0/87ornGSMS8YVWSnakLm 2uZGJSH/NNU0sFJKCxA+eSgXW0pMK0AD84lP0PF7jwAUf2sUv08QAmxbOu18ZHz8hLv0 kGC0FQnyKclljKoOrZu3qLp5Qk4eBwyITCgChNprBibgvSrpHpSDSV6NZDk9PsWLATc0 CmWg== X-Gm-Message-State: APzg51AT3ooRbUp6ZutboXSkVTuyarvA0lRopKVg/Ph49UBJHf+GsP2d JVAUEbh8lHzdfk11xeMI5EL5X77nE5QgItSrnYl6Kg== X-Received: by 2002:a0c:885b:: with SMTP id 27-v6mr2247779qvm.115.1536243915853; Thu, 06 Sep 2018 07:25:15 -0700 (PDT) MIME-Version: 1.0 References: <37f9bd824ede529fdab291a40eef3415f99ec8aa.1536138304.git.ren_guo@c-sky.com> In-Reply-To: <37f9bd824ede529fdab291a40eef3415f99ec8aa.1536138304.git.ren_guo@c-sky.com> From: Arnd Bergmann Date: Thu, 6 Sep 2018 16:24:59 +0200 Message-ID: Subject: Re: [PATCH V3 13/26] csky: Library functions To: Guo Ren Cc: linux-arch , Linux Kernel Mailing List , Thomas Gleixner , Daniel Lezcano , Jason Cooper , c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, Thomas Petazzoni , wbx@uclibc-ng.org, Greentime Hu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 5, 2018 at 2:08 PM Guo Ren wrote: > --- /dev/null > +++ b/arch/csky/abiv1/memset.c > @@ -0,0 +1,38 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. > +#include > + > +void *memset(void *dest, int c, size_t l) > +{ > + char *d = dest; > + int ch = c; > + int tmp; > + > + if ((long)d & 0x3) > + while (l--) *d++ = ch; > + else { > + ch &= 0xff; > + tmp = (ch | ch << 8 | ch << 16 | ch << 24); > + > + while (l >= 16) { > + *(((long *)d)) = tmp; > + *(((long *)d)+1) = tmp; > + *(((long *)d)+2) = tmp; > + *(((long *)d)+3) = tmp; > + l -= 16; > + d += 16; > + } > + > + while (l > 3) { > + *(((long *)d)) = tmp; > + d = d + 4; > + l -= 4; > + } > + > + while (l) { > + *d++ = ch; > + l--; > + } > + } > + return dest; > +} I see that we have a trivial memset() implementation in lib/string.c, but yours seems to be better optimized. Where did you get it from? Is this a version that works particularly well on C-Sky, or is this a generic optimized memset that others could use as well? In the latter case, we could add it to lib/string.c and let architectures select it in place of the triivial version. Arnd