Commit 88bdd4c3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] shm_get_stat-handle-hugetlb-pages.patch

From: William Lee Irwin III <wli@holomorphy.com>

shm_get_stat() didn't know about hugetlbpage-backed shm.
parent d7b557d1
...@@ -361,27 +361,35 @@ static inline unsigned long copy_shminfo_to_user(void *buf, struct shminfo64 *in ...@@ -361,27 +361,35 @@ static inline unsigned long copy_shminfo_to_user(void *buf, struct shminfo64 *in
} }
} }
static void shm_get_stat (unsigned long *rss, unsigned long *swp) static void shm_get_stat(unsigned long *rss, unsigned long *swp)
{ {
struct shmem_inode_info *info;
int i; int i;
*rss = 0; *rss = 0;
*swp = 0; *swp = 0;
for(i = 0; i <= shm_ids.max_id; i++) { for (i = 0; i <= shm_ids.max_id; i++) {
struct shmid_kernel* shp; struct shmid_kernel *shp;
struct inode * inode; struct inode *inode;
shp = shm_get(i); shp = shm_get(i);
if(shp == NULL) if(!shp)
continue; continue;
inode = shp->shm_file->f_dentry->d_inode; inode = shp->shm_file->f_dentry->d_inode;
info = SHMEM_I(inode);
spin_lock (&info->lock); if (is_file_hugepages(shp->shm_file)) {
*rss += inode->i_mapping->nrpages; struct address_space *mapping = inode->i_mapping;
*swp += info->swapped; spin_lock(&mapping->page_lock);
spin_unlock (&info->lock); *rss += (HPAGE_SIZE/PAGE_SIZE)*mapping->nrpages;
spin_unlock(&mapping->page_lock);
} else {
struct shmem_inode_info *info = SHMEM_I(inode);
spin_lock(&info->lock);
*rss += inode->i_mapping->nrpages;
*swp += info->swapped;
spin_unlock(&info->lock);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment