[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <485A9EF5.76E4.0078.0@novell.com>
Date: Thu, 19 Jun 2008 17:01:25 +0100
From: "Jan Beulich" <jbeulich@...ell.com>
To: "Jeremy Fitzhardinge" <jeremy@...p.org>
Cc: <mingo@...e.hu>, <tglx@...utronix.de>,
<linux-kernel@...r.kernel.org>, <hpa@...or.com>
Subject: Re: [PATCH] i386: fix vmalloc_sync_all() for Xen
>>>> + if (!test_bit(sync_index(address), insync)) {
>>>>
>>>>
>>> It's probably worth reversing this test and removing a layer of indentation.
>>>
>>
>> How? There's a second if() following this one, so we can't just 'continue;'
>> here.
>>
>
>That second if() block seems completely redundant:
>
> if (address == start && test_bit(pgd_index(address), insync))
> start = address + PGDIR_SIZE;
>
>All it does it update "start", but start isn't used anywhere else in the
>loop.
Since start is a static variable, it must be updated this way. The intention
here is to shorten the loop in later runs - since kernel page table entries
never go away, this is possible. Possibly just using the insync array would
be sufficient, but when I first coded this I wanted to avoid as much
overhead as was possible.
>>>> spin_lock_irqsave(&pgd_lock, flags);
>>>> + if (unlikely(list_empty(&pgd_list))) {
>>>> + spin_unlock_irqrestore(&pgd_lock, flags);
>>>> + return;
>>>> + }
>>>>
>>>>
>>> This seems a bit warty. If the list is empty, then won't the
>>> list_for_each_entry() just fall through? Presumably this only applies
>>> to boot, since pgd_list won't be empty on a running system with usermode
>>> processes. Is there a correctness issue here, or is it just a
>>> micro-optimisation?
>>>
>>
>> No, it isn't. Note the setting to NULL of page, which after the loop gets
>> tested for. list_for_each_entry() would never yield a NULL page, even
>> if the list is empty.
>
>Does that matter? If pgd_list is empty, then it's in sync by
>definition. Why does it need special-casing?
Yes, certainly. But it would result in all insync bits set, which would be
wrong - only non-empty page directory entries can be in sync.
>>>> list_for_each_entry(page, &pgd_list, lru) {
>>>> if (!vmalloc_sync_one(page_address(page),
>>>> - address))
>>>> + address)) {
>>>> + BUG_ON(list_first_entry(&pgd_list,
>>>> + struct page,
>>>> + lru) != page);
>>>>
>>>>
>>> What condition is this testing for?
>>>
>>
>> This is a replacement of the BUG_ON() that an earlier patch from you
>> removed: Failure of vmalloc_sync_one() must happen on the first
>> entry or never, and this is what is being checked for here.
>>
>
>Could you add a comment?
Sure, though there was none originally, and the intention seemed
quite clear to me.
Jan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists