This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Variations of memset()

On 08/04/2017 01:02 PM, Matthew Wilcox wrote:
> On Fri, Aug 04, 2017 at 02:09:11PM -0400, Carlos O'Donell wrote:
>> On 08/04/2017 01:11 PM, Matthew Wilcox wrote:
>>> void *memset16(uint16_t *s, uint16_t v, size_t count);
>>> void *memset32(uint32_t *s, uint32_t v, size_t count);
>>> void *memset64(uint64_t *s, uint64_t v, size_t count);
>>> void *memset_s(unsigned short *p, unsigned short v, size_t count);
>>> void *memset_i(unsigned int *p, unsigned int v, size_t count);
>>> void *memset_l(unsigned long *p, unsigned long v, size_t count);
>>> void *memset_ll(unsigned long long *p, unsigned long long v, size_t count);
>>> void *memset_p(void **p, void *v, size_t count);
>> How are users expected to use these functions?
>> What current uses to users use them for?
> I've identified three places in the Linux kernel which are quite
> dissimilar that can make use of such functions.
> 1. Initialising an array of uint32_t to a particular value.  This is part
> of the Symbios SCSI driver.  It is initialisation code.  This benefits
> from smaller code size
> 2. Decompression in the zram driver.  The zram driver can compress a page
> of RAM which consists entirely of a repeated pattern (up to the size of a
> 'long').  This benefits from the speed of memset_l.
So for these cases would it make more sense for the compiler to identify
the initialization loop and have it call into the new routines in glibc
rather than changing the kernel or various applications to call those

GCC already has the ability to identify loops that boil down to a
memset.  Extending that support to handle initializations using objects
> 8 bits in size would seem straighforward to me.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]