compaction.c (c503c193db7d7ccc0c58b1ef694eaef331318149) compaction.c (17adb230d6a6e39f9ba39440ee8441291795dff4)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/compaction.c
4 *
5 * Memory compaction for the reduction of external fragmentation. Note that
6 * this heavily depends upon page migration to do all the real heavy
7 * lifting
8 *

--- 1014 unchanged lines hidden (view full) ---

1023
1024 if (!__isolate_lru_page_prepare(page, isolate_mode))
1025 goto isolate_fail_put;
1026
1027 /* Try isolate the page */
1028 if (!TestClearPageLRU(page))
1029 goto isolate_fail_put;
1030
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/mm/compaction.c
4 *
5 * Memory compaction for the reduction of external fragmentation. Note that
6 * this heavily depends upon page migration to do all the real heavy
7 * lifting
8 *

--- 1014 unchanged lines hidden (view full) ---

1023
1024 if (!__isolate_lru_page_prepare(page, isolate_mode))
1025 goto isolate_fail_put;
1026
1027 /* Try isolate the page */
1028 if (!TestClearPageLRU(page))
1029 goto isolate_fail_put;
1030
1031 lruvec = mem_cgroup_page_lruvec(page, pgdat);
1031 lruvec = mem_cgroup_page_lruvec(page);
1032
1033 /* If we already hold the lock, we can skip some rechecking */
1034 if (lruvec != locked) {
1035 if (locked)
1036 unlock_page_lruvec_irqrestore(locked, flags);
1037
1038 compact_lock_irqsave(&lruvec->lru_lock, &flags, cc);
1039 locked = lruvec;

--- 910 unchanged lines hidden (view full) ---

1950 */
1951static inline bool is_via_compact_memory(int order)
1952{
1953 return order == -1;
1954}
1955
1956static bool kswapd_is_running(pg_data_t *pgdat)
1957{
1032
1033 /* If we already hold the lock, we can skip some rechecking */
1034 if (lruvec != locked) {
1035 if (locked)
1036 unlock_page_lruvec_irqrestore(locked, flags);
1037
1038 compact_lock_irqsave(&lruvec->lru_lock, &flags, cc);
1039 locked = lruvec;

--- 910 unchanged lines hidden (view full) ---

1950 */
1951static inline bool is_via_compact_memory(int order)
1952{
1953 return order == -1;
1954}
1955
1956static bool kswapd_is_running(pg_data_t *pgdat)
1957{
1958 return pgdat->kswapd && task_is_running(pgdat->kswapd);
1958 return pgdat->kswapd && (pgdat->kswapd->state == TASK_RUNNING);
1959}
1960
1961/*
1962 * A zone's fragmentation score is the external fragmentation wrt to the
1963 * COMPACTION_HPAGE_ORDER. It returns a value in the range [0, 100].
1964 */
1965static unsigned int fragmentation_score_zone(struct zone *zone)
1966{

--- 750 unchanged lines hidden (view full) ---

2717{
2718 if (write)
2719 compact_nodes();
2720
2721 return 0;
2722}
2723
2724#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
1959}
1960
1961/*
1962 * A zone's fragmentation score is the external fragmentation wrt to the
1963 * COMPACTION_HPAGE_ORDER. It returns a value in the range [0, 100].
1964 */
1965static unsigned int fragmentation_score_zone(struct zone *zone)
1966{

--- 750 unchanged lines hidden (view full) ---

2717{
2718 if (write)
2719 compact_nodes();
2720
2721 return 0;
2722}
2723
2724#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
2725static ssize_t sysfs_compact_node(struct device *dev,
2726 struct device_attribute *attr,
2727 const char *buf, size_t count)
2725static ssize_t compact_store(struct device *dev,
2726 struct device_attribute *attr,
2727 const char *buf, size_t count)
2728{
2729 int nid = dev->id;
2730
2731 if (nid >= 0 && nid < nr_node_ids && node_online(nid)) {
2732 /* Flush pending updates to the LRU lists */
2733 lru_add_drain_all();
2734
2735 compact_node(nid);
2736 }
2737
2738 return count;
2739}
2728{
2729 int nid = dev->id;
2730
2731 if (nid >= 0 && nid < nr_node_ids && node_online(nid)) {
2732 /* Flush pending updates to the LRU lists */
2733 lru_add_drain_all();
2734
2735 compact_node(nid);
2736 }
2737
2738 return count;
2739}
2740static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node);
2740static DEVICE_ATTR_WO(compact);
2741
2742int compaction_register_node(struct node *node)
2743{
2744 return device_create_file(&node->dev, &dev_attr_compact);
2745}
2746
2747void compaction_unregister_node(struct node *node)
2748{

--- 268 unchanged lines hidden ---
2741
2742int compaction_register_node(struct node *node)
2743{
2744 return device_create_file(&node->dev, &dev_attr_compact);
2745}
2746
2747void compaction_unregister_node(struct node *node)
2748{

--- 268 unchanged lines hidden ---