Skip to contentSkip to conversation

page allocation in nfs_symlink

DISCUSSION Jeff Layton 2 participants 7 messages Jun 7, 2007 – Jun 27, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Am I missing something?

Thanks,

Signature · 10 lines
Jeff Layton <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#1 lore raw
Quoted 20 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Quoted 7 lines

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Am I missing something?

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw
Quoted 27 lines · On Thu, 07 Jun 2007 09:28:23 -0400 Trond Myklebust…
Quoted 26 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Quoted 7 lines
Quoted 1 line

Am I missing something?

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

Ok. For the sake of completeness, here's a patch. I've not tested it, however.

fs/nfs/dir.c +1 -1
index c27258b..731f112 100644
@@ -1535,7 +1535,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
 
 	lock_kernel();
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(GFP_HIGHUSER);
 	if (!page) {
 		unlock_kernel();
 		return -ENOMEM;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#3 lore raw
Quoted 32 lines · Jeff Layton
Quoted 29 lines · On Thu, 07 Jun 2007 09:28:23 -0400 Trond Myklebust…
Quoted 27 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Am I missing something?

Quoted 8 lines
Quoted 5 lines

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

Ok. For the sake of completeness, here's a patch. I've not tested it, however.

Could you throw in a little changelog entry too, please? :-)

Trond

Quoted 7 lines
fs/nfs/dir.c +0 -0
index c27258b..731f112 100644

fs/nfs/dir.c static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym · line 1541

Quoted 8 lines
fs/nfs/dir.c +1 -1
@@ -1535,7 +1535,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
 
 	lock_kernel();
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(GFP_HIGHUSER);
 	if (!page) {
 		unlock_kernel();
 		return -ENOMEM;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#4 lore raw
Quoted 39 lines · On Thu, 07 Jun 2007 09:46:19 -0400 Trond Myklebust…
Quoted 38 lines · Jeff Layton
Quoted 34 lines · On Thu, 07 Jun 2007 09:28:23 -0400 Trond Myklebust…
Quoted 20 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Quoted 7 lines

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Am I missing something?

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

Quoted 7 lines
Quoted 2 lines

Ok. For the sake of completeness, here's a patch. I've not tested it, however.

Could you throw in a little changelog entry too, please? :-)

Trond

Is this enough, or do you want something more elaborate? :-)

--------[snip]--------

It should be safe to use high memory for symlink pages.

fs/nfs/dir.c +1 -1
index c27258b..731f112 100644
@@ -1535,7 +1535,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
 
 	lock_kernel();
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(GFP_HIGHUSER);
 	if (!page) {
 		unlock_kernel();
 		return -ENOMEM;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#5 lore raw

Re: page allocation in nfs_symlink (repost)

In reply to Trond Myklebust
Quoted 39 lines · On Thu, 07 Jun 2007 09:46:19 -0400 Trond Myklebust…
Quoted 38 lines · Jeff Layton
Quoted 34 lines · On Thu, 07 Jun 2007 09:28:23 -0400 Trond Myklebust…
Quoted 20 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Quoted 7 lines

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Am I missing something?

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

Quoted 7 lines
Quoted 2 lines

Ok. For the sake of completeness, here's a patch. I've not tested it, however.

Could you throw in a little changelog entry too, please? :-)

Trond

Hi Trond,
You never responded to my last post here and I noticed that this
patch hadn't made it into your git tree. Does this look OK?

------------[snip]--------------

NFS: Use GFP_HIGHUSER for page allocation in nfs_symlink()

nfs_symlink() allocates a GFP_KERNEL page for the pagecache. Most pagecache pages are allocated using GFP_HIGHUSER, and there's no reason not to do that in nfs_symlink() as well.

fs/nfs/dir.c +1 -1
index 69e9c0a..322141f 100644
@@ -1534,7 +1534,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
 
 	lock_kernel();
 
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(GFP_HIGHUSER);
 	if (!page) {
 		unlock_kernel();
 		return -ENOMEM;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#6 lore raw

Re: page allocation in nfs_symlink (repost)

Quoted 45 lines · Jeff Layton
Quoted 42 lines · On Thu, 07 Jun 2007 09:46:19 -0400 Trond Myklebust…
Quoted 40 lines · Jeff Layton
Quoted 27 lines · On Thu, 07 Jun 2007 09:28:23 -0400 Trond Myklebust…
Quoted 26 lines · Jeff Layton

I was reviewing a patch the other day and noticed this in recent versions of nfs_symlink():

        page = alloc_page(GFP_KERNEL);
        if (!page) {
                unlock_kernel();
                return -ENOMEM;
        }

        kaddr = kmap_atomic(page, KM_USER0);
        memcpy(kaddr, symname, pathlen);
        if (pathlen < PAGE_SIZE)
                memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
        kunmap_atomic(kaddr, KM_USER0);

I'm a bit confused and so am hoping someone can clarify. If we're allocating a GFP_KERNEL page, then it should be directly addressable by the kernel (via page_address()). So we really shouldn't need to use a kmap/unmap here, right?

Also, it looks like most pagecache pages are allocated using GFP_HIGHUSER. Is there something special about symlinks that means that we need to use normal zone pages here? While I haven't tested it, it seems like we ought to be able to do alloc_page(GFP_HIGHUSER) here instead.

Quoted 7 lines
Quoted 1 line

Am I missing something?

No. I think you're right: it should be safe to use GFP_HIGHUSER.

Cheers
Trond

Ok. For the sake of completeness, here's a patch. I've not tested it, however.

Quoted 8 lines
Quoted 4 lines

Could you throw in a little changelog entry too, please? :-)

Trond

Hi Trond,
You never responded to my last post here and I noticed that this
patch hadn't made it into your git tree. Does this look OK?

Sorry. I got half-way through the process of extracting the patch, then apparently got distracted: I found it still in my home directory, but not in my stgit tree...

Anyhow. Applied now... I'm waiting for CITI to come back online (we had a storm) so that I can update the NFS git tree...

Trond

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs