Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp703749imm; Thu, 6 Sep 2018 08:51:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZfEHpYiph0y0z2OgA2E8AyNYuNTiaTp72PvIl3UUAZl5D5k65ivltpqIZxunTKOxOVpFZX X-Received: by 2002:a63:6385:: with SMTP id x127-v6mr3424385pgb.413.1536249119615; Thu, 06 Sep 2018 08:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536249119; cv=none; d=google.com; s=arc-20160816; b=nu0YFSFV6YdJ5/Y0ZPkaRoe/lbRZ+FVvS60XnvIIkZgx63v371l/fR21odCr/1jLqm B6krLc4xV1OU1Xn3zYExGvGYGXeiMFy8/qNYWRHI/vG1Igl4GsE0pM9/v5w3XIPFvRN9 d1INqNYWdIwO+jYKi67ugjtzIUM4VpePdmzgPUFYky0rUl00k5FVwoWtnQjrcoDjkevt q4EWnPufBoholscJP51/6H6+DbXn90kjsGDGcBzYosvIMBzI7/+ax+KNhZ46w1/1aaXR psuNFG6Agjtqs9GHxU36lK3eWSbnNO3xjUlezlF+CgER3bqX6HCDjckwSoz0A5dpz05M 27SQ== 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=v4CoNjz5LWKVHNmcUkPM+OrYMGblOSGorYX19e/KK88=; b=Qh9QHaOP9h+MY/saLA7nIO9hDhmGJDfmpBY2IuC/y7WRIuMj/w+72Xq49ZQL16mRfz oKh6x86miLQ7OHa3+tqviXENohnPHAEg8tSuDOkC52iMnqbUNpe2RTjhREpONxJlASLb Ugu2SxdsUTeJjXpCBTm0BSfGVEM+P92QGvE15LoQrSUXaaK/ugHG07TV6GzVcpBul+FE 6Fk+cWzVPPrhgs4xSVrIYXxmEuBVG1zMtApPIdcI5++Wkb8XTZ3+nI3lRDRPu9gXVjLQ ZZHJSM1XQuDW2c/tUzMWPU1hUJWzM6Acs89K/QZrGv0oZJHtFQllpmnMQYUcwVE4AVXD HLFA== 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 o11-v6si6038142pgf.71.2018.09.06.08.51.42; Thu, 06 Sep 2018 08:51:59 -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 S1730360AbeIFU0Y (ORCPT + 99 others); Thu, 6 Sep 2018 16:26:24 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:36663 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730122AbeIFU0X (ORCPT ); Thu, 6 Sep 2018 16:26:23 -0400 Received: by mail-ua1-f65.google.com with SMTP id c12-v6so9184608uan.3; Thu, 06 Sep 2018 08:50: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=v4CoNjz5LWKVHNmcUkPM+OrYMGblOSGorYX19e/KK88=; b=DQnuO8aZrVO13+KYApwanUzzNhl/i/VJ3w/sBVmOQpt9JEbUn+j4QtqCOx/vIwoUAd I/O4HDGbxm4tqg9Syvlknw0Snk1fhDrtjbkSHKr2YawTbBh12dvrTPRd8P8rwVEHf9g0 X7Dl8e8GYyH2Gplu63YjhHgL3s4XDeYYjrkP5bj1V3mMP+OTpFGu6mpnR9XEiTI6zhnJ gw695rUrncaEJrWzep0XfURUMB8+KptZmR3Q5pX/eU5C6DK8S5fOuiBeXs4KVGDLWR5S CErnAvHAGIqBWDCiPsZhXaNtSbILlGwccIdv9S1Mwqkwborrn6A0tq1iIWVUJ26ZZ1mT cWwg== X-Gm-Message-State: APzg51BIEtm3SGY8ADVEbbdFB01laZshOYIZ4eTHhLG+0HS/M8SzOaw9 QIss46Mxi433ze2SHgead77Br5EehWx7PNJpmn0= X-Received: by 2002:ab0:51ac:: with SMTP id g41-v6mr1307293uaa.155.1536249015473; Thu, 06 Sep 2018 08:50:15 -0700 (PDT) MIME-Version: 1.0 References: <37f9bd824ede529fdab291a40eef3415f99ec8aa.1536138304.git.ren_guo@c-sky.com> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 6 Sep 2018 17:50:02 +0200 Message-ID: Subject: Re: [PATCH V3 13/26] csky: Library functions To: Arnd Bergmann Cc: Guo Ren , 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 Thu, Sep 6, 2018 at 4:25 PM Arnd Bergmann wrote: > 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; while ((uintptr_t)d & 0x3) && l--) *d++ =ch; and remove the else below? > > + 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; s/long/u32/ > > + 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. Sounds good to me, after removing the 32-bit-isms. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds