OSDN Git Service

Merge tag 'driver-core-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[uclinux-h8/linux.git] / mm / workingset.c
index 8c03afe..8a3828a 100644 (file)
@@ -245,31 +245,32 @@ void workingset_age_nonresident(struct lruvec *lruvec, unsigned long nr_pages)
 }
 
 /**
- * workingset_eviction - note the eviction of a page from memory
+ * workingset_eviction - note the eviction of a folio from memory
  * @target_memcg: the cgroup that is causing the reclaim
- * @page: the page being evicted
+ * @folio: the folio being evicted
  *
- * Return: a shadow entry to be stored in @page->mapping->i_pages in place
- * of the evicted @page so that a later refault can be detected.
+ * Return: a shadow entry to be stored in @folio->mapping->i_pages in place
+ * of the evicted @folio so that a later refault can be detected.
  */
-void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg)
+void *workingset_eviction(struct folio *folio, struct mem_cgroup *target_memcg)
 {
-       struct pglist_data *pgdat = page_pgdat(page);
+       struct pglist_data *pgdat = folio_pgdat(folio);
        unsigned long eviction;
        struct lruvec *lruvec;
        int memcgid;
 
-       /* Page is fully exclusive and pins page's memory cgroup pointer */
-       VM_BUG_ON_PAGE(PageLRU(page), page);
-       VM_BUG_ON_PAGE(page_count(page), page);
-       VM_BUG_ON_PAGE(!PageLocked(page), page);
+       /* Folio is fully exclusive and pins folio's memory cgroup pointer */
+       VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
+       VM_BUG_ON_FOLIO(folio_ref_count(folio), folio);
+       VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
 
        lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
        /* XXX: target_memcg can be NULL, go through lruvec */
        memcgid = mem_cgroup_id(lruvec_memcg(lruvec));
        eviction = atomic_long_read(&lruvec->nonresident_age);
-       workingset_age_nonresident(lruvec, thp_nr_pages(page));
-       return pack_shadow(memcgid, pgdat, eviction, PageWorkingset(page));
+       workingset_age_nonresident(lruvec, folio_nr_pages(folio));
+       return pack_shadow(memcgid, pgdat, eviction,
+                               folio_test_workingset(folio));
 }
 
 /**
@@ -429,10 +430,12 @@ out:
  * point where they would still be useful.
  */
 
-static struct list_lru shadow_nodes;
+struct list_lru shadow_nodes;
 
 void workingset_update_node(struct xa_node *node)
 {
+       struct address_space *mapping;
+
        /*
         * Track non-empty nodes that contain only shadow entries;
         * unlink those that contain pages or are being freed.
@@ -441,7 +444,8 @@ void workingset_update_node(struct xa_node *node)
         * already where they should be. The list_empty() test is safe
         * as node->private_list is protected by the i_pages lock.
         */
-       VM_WARN_ON_ONCE(!irqs_disabled());  /* For __inc_lruvec_page_state */
+       mapping = container_of(node->array, struct address_space, i_pages);
+       lockdep_assert_held(&mapping->i_pages.xa_lock);
 
        if (node->count && node->count == node->nr_values) {
                if (list_empty(&node->private_list)) {