mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Randy Dunlap" <rdunlap@xenotime.net>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Ingo Molnar" <mingo@elte.hu>,
	"Pekka Enberg" <penberg@cs.helsinki.fi>,
	"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/13] kmemcheck: add the kmemcheck core
Date: Fri, 18 Jul 2008 01:23:41 +0200	[thread overview]
Message-ID: <19f34abd0807171623j15e2e940rac790567f5874a87@mail.gmail.com> (raw)
In-Reply-To: <20080717144933.8951a558.rdunlap@xenotime.net>

On Thu, Jul 17, 2008 at 11:49 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:
> On Wed, 16 Jul 2008 02:23:29 +0200 Vegard Nossum wrote:
>
>> >From fcd8f514a8962ea22aafb831b9f22a2ea1a13870 Mon Sep 17 00:00:00 2001
>
> eh?

Uhm, probably relative to my previous patch? About the date, I have no
idea. All my "git format-patch" output looks like this.

>> +++ b/arch/x86/mm/kmemcheck/error.h
>> @@ -0,0 +1,15 @@
>> +#ifndef ARCH__X86__MM__KMEMCHECK__ERROR_H
>> +#define ARCH__X86__MM__KMEMCHECK__ERROR_H
>
> We don't usually use double __ here.

But it's such a nice convention! How can we differentiate between
mm/types.h and mm_types.h!

>> +void *kmemcheck_memset(void *s, int c, size_t n)
>> +{
>> +     unsigned long addr;
>> +     unsigned long start_page, start_offset;
>> +     unsigned long end_page, end_offset;
>> +     unsigned long i;
>> +
>> +     if (!n)
>> +             return s;
>> +
>> +     if (!slab_is_available()) {
>> +             __memset(s, c, n);
>> +             return s;
>> +     }
>> +
>> +     addr = (unsigned long) s;
>> +
>> +     start_page = addr & PAGE_MASK;
>> +     end_page = (addr + n) & PAGE_MASK;
>> +
>> +     if (start_page == end_page) {
>> +             /* The entire area is within the same page. Good, we only
>> +              * need one memset(). */
>> +             memset_one_page(s, c, n);
>> +             return s;
>> +     }
>> +
>> +     start_offset = addr & ~PAGE_MASK;
>> +     end_offset = (addr + n) & ~PAGE_MASK;
>> +
>> +     /* Clear the head, body, and tail of the memory area. */
>> +     if (start_offset < PAGE_SIZE)
>> +             memset_one_page(s, c, PAGE_SIZE - start_offset);
>> +     for (i = start_page + PAGE_SIZE; i < end_page; i += PAGE_SIZE)
>> +             memset_one_page((void *) i, c, PAGE_SIZE);
>> +     if (end_offset > 0)
>> +             memset_one_page((void *) end_page, c, end_offset);
>> +
>> +     return s;
>> +}
>> +
>> +EXPORT_SYMBOL(kmemcheck_memset);
>
> We would prefer to have kernel-doc on exported functions...

Oops. I will not add a kernel-doc, but I will add an explanation.

This function is a drop-in replacement for memset, and the reason for
the EXPORT is that the real memset() in fact is just a macro that
calls this function. And memset is needed in modules. This function
should not actually have any users beside the memset() in x86 headers.

Thanks for mini-review! (Does this mean the rest was okay? :-D)


Vegard

-- 
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036

  reply	other threads:[~2008-07-17 23:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-16  0:23 Vegard Nossum
2008-07-17 21:49 ` Randy Dunlap
2008-07-17 23:23   ` Vegard Nossum [this message]
2008-07-17 23:32     ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19f34abd0807171623j15e2e940rac790567f5874a87@mail.gmail.com \
    --to=vegard.nossum@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®