From: Izik Eidus <ieidus@redhat.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-mm@kvack.org, avi@redhat.com, aarcange@redhat.com,
chrisw@redhat.com, mtosatti@redhat.com, hugh@veritas.com,
kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [PATCH 4/4] add ksm kernel shared memory driver.
Date: Thu, 16 Apr 2009 03:57:17 +0300 [thread overview]
Message-ID: <49E6826D.7050407@redhat.com> (raw)
In-Reply-To: <49E67F17.1070805@goop.org>
Jeremy Fitzhardinge wrote:
> Andrew Morton wrote:
>>> +static pte_t *get_pte(struct mm_struct *mm, unsigned long addr)
>>> +{
>>> + pgd_t *pgd;
>>> + pud_t *pud;
>>> + pmd_t *pmd;
>>> + pte_t *ptep = NULL;
>>> +
>>> + pgd = pgd_offset(mm, addr);
>>> + if (!pgd_present(*pgd))
>>> + goto out;
>>> +
>>> + pud = pud_offset(pgd, addr);
>>> + if (!pud_present(*pud))
>>> + goto out;
>>> +
>>> + pmd = pmd_offset(pud, addr);
>>> + if (!pmd_present(*pmd))
>>> + goto out;
>>> +
>>> + ptep = pte_offset_map(pmd, addr);
>>> +out:
>>> + return ptep;
>>> +}
>>>
>>
>> hm, this looks very generic. Does it duplicate anything which core
>> kernel already provides? If not, perhaps core kernel should provide
>> this (perhaps after some reorganisation).
>>
>
> It is lookup_address() which works on user addresses, and as such is
> very useful.
But ksm need the pgd offset of an mm struct, not the kernel pgd, so
maybe changing it to get the pgd offset would be nice..
Another thing it is just for x86 right now, so probably it need to go
out to the common code
> But it would need to deal with returning a level so it can deal with
> large pages in usermode, and have some well-defined semantics on
> whether the caller is responsible for unmapping the returned thing
> (ie, only if its a pte).
>
> I implemented this myself a couple of months ago, but I can't find it
> anywhere...
>
>>> +static int memcmp_pages(struct page *page1, struct page *page2)
>>> +{
>>> + char *addr1, *addr2;
>>> + int r;
>>> +
>>> + addr1 = kmap_atomic(page1, KM_USER0);
>>> + addr2 = kmap_atomic(page2, KM_USER1);
>>> + r = memcmp(addr1, addr2, PAGE_SIZE);
>>> + kunmap_atomic(addr1, KM_USER0);
>>> + kunmap_atomic(addr2, KM_USER1);
>>> + return r;
>>> +}
>>>
>>
>> I wonder if this code all does enough cpu cache flushing to be able to
>> guarantee that it's looking at valid data. Not my area, and presumably
>> not an issue on x86.
>>
>
> Shouldn't that be kmap_atomic's job anyway? Otherwise it would be
> hard to use on any virtual-tag/indexed cache machine.
>
> J
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-04-16 0:57 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 3:58 [PATCH 0/4] ksm - dynamic page sharing driver for linux v3 Izik Eidus
2009-04-09 3:58 ` [PATCH 1/4] MMU_NOTIFIERS: add set_pte_at_notify() Izik Eidus
2009-04-09 3:58 ` [PATCH 2/4] add page_wrprotect(): write protecting page Izik Eidus
2009-04-09 3:58 ` [PATCH 3/4] add replace_page(): change the page pte is pointing to Izik Eidus
2009-04-09 3:58 ` [PATCH 4/4] add ksm kernel shared memory driver Izik Eidus
2009-04-14 22:09 ` Andrew Morton
2009-04-15 22:37 ` Izik Eidus
2009-04-15 22:50 ` Andrew Morton
2009-04-15 23:21 ` Andrea Arcangeli
2009-04-16 0:43 ` Jeremy Fitzhardinge
2009-04-16 0:57 ` Izik Eidus [this message]
2009-04-16 11:39 ` Andrea Arcangeli
2009-04-16 16:08 ` Jeremy Fitzhardinge
2009-04-18 14:58 ` Andrea Arcangeli
2009-04-14 22:09 ` [PATCH 3/4] add replace_page(): change the page pte is pointing to Andrew Morton
2009-04-15 11:25 ` Andrea Arcangeli
2009-04-15 22:48 ` Izik Eidus
2009-04-14 22:09 ` [PATCH 0/4] ksm - dynamic page sharing driver for linux v3 Andrew Morton
2009-04-16 17:55 ` Nick Piggin
2009-04-16 18:25 ` Izik Eidus
2009-04-17 7:08 ` Jared Hulbert
2009-04-21 2:59 ` Nick Piggin
-- strict thread matches above, loose matches on Subject: below --
2009-04-04 14:35 [PATCH 0/4] ksm - dynamic page sharing driver for linux v2 Izik Eidus
2009-04-04 14:35 ` [PATCH 1/4] MMU_NOTIFIERS: add set_pte_at_notify() Izik Eidus
2009-04-04 14:35 ` [PATCH 2/4] add page_wrprotect(): write protecting page Izik Eidus
2009-04-04 14:35 ` [PATCH 3/4] add replace_page(): change the page pte is pointing to Izik Eidus
2009-04-04 14:35 ` [PATCH 4/4] add ksm kernel shared memory driver Izik Eidus
2009-04-06 9:13 ` Andrey Panin
2009-04-06 10:58 ` Izik Eidus
2009-03-30 23:59 [PATCH 0/4] ksm - dynamic page sharing driver for linux Izik Eidus
2009-03-30 23:59 ` [PATCH 1/4] MMU_NOTIFIERS: add set_pte_at_notify() Izik Eidus
2009-03-30 23:59 ` [PATCH 2/4] add page_wrprotect(): write protecting page Izik Eidus
2009-03-30 23:59 ` [PATCH 3/4] add replace_page(): change the page pte is pointing to Izik Eidus
2009-03-30 23:59 ` [PATCH 4/4] add ksm kernel shared memory driver Izik Eidus
2009-03-31 2:12 ` Anthony Liguori
2009-03-31 12:24 ` Izik Eidus
2009-03-31 13:31 ` Anthony Liguori
2009-03-31 14:25 ` Andrea Arcangeli
2009-03-31 14:37 ` Anthony Liguori
2009-03-31 15:02 ` Andrea Arcangeli
2009-03-31 15:09 ` Anthony Liguori
2009-03-31 15:18 ` Andrea Arcangeli
2009-03-31 15:54 ` Anthony Liguori
2009-03-31 16:25 ` Andrea Arcangeli
2009-03-31 16:51 ` Anthony Liguori
2009-03-31 17:11 ` Andrea Arcangeli
2009-04-01 22:54 ` Izik Eidus
2009-04-02 0:31 ` Anthony Liguori
2009-04-02 0:48 ` Chris Wright
2009-04-02 1:22 ` Chris Wright
2009-04-02 2:36 ` Anthony Liguori
2009-04-02 7:24 ` Avi Kivity
2009-04-02 9:38 ` Andrea Arcangeli
2009-04-02 11:23 ` Izik Eidus
2009-03-31 2:15 ` KAMEZAWA Hiroyuki
2009-03-31 12:21 ` Izik Eidus
2009-03-31 23:57 ` KAMEZAWA Hiroyuki
2009-04-01 17:28 ` Izik Eidus
2009-03-31 20:52 ` Andrea Arcangeli
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=49E6826D.7050407@redhat.com \
--to=ieidus@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=chrisw@redhat.com \
--cc=hugh@veritas.com \
--cc=jeremy@goop.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mtosatti@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).