Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252059
b: refs/heads/master
c: 997c136
h: refs/heads/master
i:
  252057: 8c5b7e0
  252055: 27c2bb1
v: v3
  • Loading branch information
Olaf Hering authored and Linus Torvalds committed May 27, 2011
1 parent 52ed6c3 commit 57ad575
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 98bc93e505c03403479c6669c4ff97301cee6199
refs/heads/master: 997c136f518c5debd63847e78e2a8694f56dcf90
52 changes: 49 additions & 3 deletions trunk/fs/proc/vmcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,46 @@ static u64 vmcore_size;

static struct proc_dir_entry *proc_vmcore = NULL;

/*
* Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error
* The called function has to take care of module refcounting.
*/
static int (*oldmem_pfn_is_ram)(unsigned long pfn);

int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn))
{
if (oldmem_pfn_is_ram)
return -EBUSY;
oldmem_pfn_is_ram = fn;
return 0;
}
EXPORT_SYMBOL_GPL(register_oldmem_pfn_is_ram);

void unregister_oldmem_pfn_is_ram(void)
{
oldmem_pfn_is_ram = NULL;
wmb();
}
EXPORT_SYMBOL_GPL(unregister_oldmem_pfn_is_ram);

static int pfn_is_ram(unsigned long pfn)
{
int (*fn)(unsigned long pfn);
/* pfn is ram unless fn() checks pagetype */
int ret = 1;

/*
* Ask hypervisor if the pfn is really ram.
* A ballooned page contains no data and reading from such a page
* will cause high load in the hypervisor.
*/
fn = oldmem_pfn_is_ram;
if (fn)
ret = fn(pfn);

return ret;
}

/* Reads a page from the oldmem device from given offset. */
static ssize_t read_from_oldmem(char *buf, size_t count,
u64 *ppos, int userbuf)
Expand All @@ -55,9 +95,15 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
else
nr_bytes = count;

tmp = copy_oldmem_page(pfn, buf, nr_bytes, offset, userbuf);
if (tmp < 0)
return tmp;
/* If pfn is not ram, return zeros for sparse dump files */
if (pfn_is_ram(pfn) == 0)
memset(buf, 0, nr_bytes);
else {
tmp = copy_oldmem_page(pfn, buf, nr_bytes,
offset, userbuf);
if (tmp < 0)
return tmp;
}
*ppos += nr_bytes;
count -= nr_bytes;
buf += nr_bytes;
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/crash_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ static inline void vmcore_unusable(void)
if (is_kdump_kernel())
elfcorehdr_addr = ELFCORE_ADDR_ERR;
}

#define HAVE_OLDMEM_PFN_IS_RAM 1
extern int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn));
extern void unregister_oldmem_pfn_is_ram(void);

#else /* !CONFIG_CRASH_DUMP */
static inline int is_kdump_kernel(void) { return 0; }
#endif /* CONFIG_CRASH_DUMP */
Expand Down

0 comments on commit 57ad575

Please sign in to comment.