Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4220f98 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'hwpoison' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6: (34 commits)
  HWPOISON: Remove stray phrase in a comment
  HWPOISON: Try to allocate migration page on the same node
  HWPOISON: Don't do early filtering if filter is disabled
  HWPOISON: Add a madvise() injector for soft page offlining
  HWPOISON: Add soft page offline support
  HWPOISON: Undefine short-hand macros after use to avoid namespace conflict
  HWPOISON: Use new shake_page in memory_failure
  HWPOISON: Use correct name for MADV_HWPOISON in documentation
  HWPOISON: mention HWPoison in Kconfig entry
  HWPOISON: Use get_user_page_fast in hwpoison madvise
  HWPOISON: add an interface to switch off/on all the page filters
  HWPOISON: add memory cgroup filter
  memcg: add accessor to mem_cgroup.css
  memcg: rename and export try_get_mem_cgroup_from_page()
  HWPOISON: add page flags filter
  mm: export stable page flags
  HWPOISON: limit hwpoison injector to known page types
  HWPOISON: add fs/device filters
  HWPOISON: return 0 to indicate success reliably
  HWPOISON: make semantics of IGNORED/DELAYED clear
  ...
parents 61cf6931 f2c03deb
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
What:		/sys/devices/system/memory/soft_offline_page
Date:		Sep 2009
KernelVersion:	2.6.33
Contact:	andi@firstfloor.org
Description:
		Soft-offline the memory page containing the physical address
		written into this file. Input is a hex number specifying the
		physical address of the page. The kernel will then attempt
		to soft-offline it, by moving the contents elsewhere or
		dropping it if possible. The kernel will then be placed
		on the bad page list and never be reused.

		The offlining is done in kernel specific granuality.
		Normally it's the base page size of the kernel, but
		this might change.

		The page must be still accessible, not poisoned. The
		kernel will never kill anything for this, but rather
		fail the offline.  Return value is the size of the
		number, or a error when the offlining failed.  Reading
		the file is not allowed.

What:		/sys/devices/system/memory/hard_offline_page
Date:		Sep 2009
KernelVersion:	2.6.33
Contact:	andi@firstfloor.org
Description:
		Hard-offline the memory page containing the physical
		address written into this file. Input is a hex number
		specifying the physical address of the page. The
		kernel will then attempt to hard-offline the page, by
		trying to drop the page or killing any owner or
		triggering IO errors if needed.  Note this may kill
		any processes owning the page. The kernel will avoid
		to access this page assuming it's poisoned by the
		hardware.

		The offlining is done in kernel specific granuality.
		Normally it's the base page size of the kernel, but
		this might change.

		Return value is the size of the number, or a error when
		the offlining failed.
		Reading the file is not allowed.
+49 −3
Original line number Diff line number Diff line
@@ -92,16 +92,62 @@ PR_MCE_KILL_GET

Testing:

madvise(MADV_POISON, ....)
madvise(MADV_HWPOISON, ....)
	(as root)
	Poison a page in the process for testing


hwpoison-inject module through debugfs
	/sys/debug/hwpoison/corrupt-pfn

Inject hwpoison fault at PFN echoed into this file
/sys/debug/hwpoison/

corrupt-pfn

Inject hwpoison fault at PFN echoed into this file. This does
some early filtering to avoid corrupted unintended pages in test suites.

unpoison-pfn

Software-unpoison page at PFN echoed into this file. This
way a page can be reused again.
This only works for Linux injected failures, not for real
memory failures.

Note these injection interfaces are not stable and might change between
kernel versions

corrupt-filter-dev-major
corrupt-filter-dev-minor

Only handle memory failures to pages associated with the file system defined
by block device major/minor.  -1U is the wildcard value.
This should be only used for testing with artificial injection.

corrupt-filter-memcg

Limit injection to pages owned by memgroup. Specified by inode number
of the memcg.

Example:
        mkdir /cgroup/hwpoison

        usemem -m 100 -s 1000 &
        echo `jobs -p` > /cgroup/hwpoison/tasks

        memcg_ino=$(ls -id /cgroup/hwpoison | cut -f1 -d' ')
        echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg

        page-types -p `pidof init`   --hwpoison  # shall do nothing
        page-types -p `pidof usemem` --hwpoison  # poison its pages

corrupt-filter-flags-mask
corrupt-filter-flags-value

When specified, only poison pages if ((page_flags & mask) == value).
This allows stress testing of many kinds of pages. The page_flags
are the same as in /proc/kpageflags. The flag bits are defined in
include/linux/kernel-page-flags.h and documented in
Documentation/vm/pagemap.txt

Architecture specific MCE injector

+13 −2
Original line number Diff line number Diff line
/*
 * page-types: Tool for querying page flags
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; version 2.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should find a copy of v2 of the GNU General Public License somewhere on
 * your Linux system; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *
 * Copyright (C) 2009 Intel corporation
 *
 * Authors: Wu Fengguang <fengguang.wu@intel.com>
 *
 * Released under the General Public License (GPL).
 */

#define _LARGEFILE64_SOURCE
+9 −0
Original line number Diff line number Diff line
@@ -2377,6 +2377,15 @@ W: http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/
S:	Maintained
F:	drivers/hwmon/hdaps.c

HWPOISON MEMORY FAILURE HANDLING
M:	Andi Kleen <andi@firstfloor.org>
L:	linux-mm@kvack.org
L:	linux-kernel@vger.kernel.org
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6.git hwpoison
S:	Maintained
F:	mm/memory-failure.c
F:	mm/hwpoison-inject.c

HYPERVISOR VIRTUAL CONSOLE DRIVER
L:	linuxppc-dev@ozlabs.org
S:	Odd Fixes
+61 −0
Original line number Diff line number Diff line
@@ -341,6 +341,64 @@ static inline int memory_probe_init(void)
}
#endif

#ifdef CONFIG_MEMORY_FAILURE
/*
 * Support for offlining pages of memory
 */

/* Soft offline a page */
static ssize_t
store_soft_offline_page(struct class *class, const char *buf, size_t count)
{
	int ret;
	u64 pfn;
	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;
	if (strict_strtoull(buf, 0, &pfn) < 0)
		return -EINVAL;
	pfn >>= PAGE_SHIFT;
	if (!pfn_valid(pfn))
		return -ENXIO;
	ret = soft_offline_page(pfn_to_page(pfn), 0);
	return ret == 0 ? count : ret;
}

/* Forcibly offline a page, including killing processes. */
static ssize_t
store_hard_offline_page(struct class *class, const char *buf, size_t count)
{
	int ret;
	u64 pfn;
	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;
	if (strict_strtoull(buf, 0, &pfn) < 0)
		return -EINVAL;
	pfn >>= PAGE_SHIFT;
	ret = __memory_failure(pfn, 0, 0);
	return ret ? ret : count;
}

static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page);
static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page);

static __init int memory_fail_init(void)
{
	int err;

	err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
				&class_attr_soft_offline_page.attr);
	if (!err)
		err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
				&class_attr_hard_offline_page.attr);
	return err;
}
#else
static inline int memory_fail_init(void)
{
	return 0;
}
#endif

/*
 * Note that phys_device is optional.  It is here to allow for
 * differentiation between which *physical* devices each
@@ -471,6 +529,9 @@ int __init memory_dev_init(void)
	}

	err = memory_probe_init();
	if (!ret)
		ret = err;
	err = memory_fail_init();
	if (!ret)
		ret = err;
	err = block_size_init();
Loading