Commit 2c04d67e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
 "11 patches.

  Subsystems affected by this patch series: mm (memcg, memory-failure,
  oom-kill, secretmem, vmalloc, hugetlb, damon, and tools), and ocfs2"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
  tools/testing/selftests/vm/split_huge_page_test.c: fix application of sizeof to pointer
  mm/damon/core-test: fix wrong expectations for 'damon_split_regions_of()'
  mm: khugepaged: skip huge page collapse for special files
  mm, thp: bail out early in collapse_file for writeback page
  mm/vmalloc: fix numa spreading for large hash tables
  mm/secretmem: avoid letting secretmem_users drop to zero
  ocfs2: fix race between searching chunks and release journal_head from buffer_head
  mm/oom_kill.c: prevent a race between process_mrelease and exit_mmap
  mm: filemap: check if THP has hwpoisoned subpage for PMD page fault
  mm: hwpoison: remove the unnecessary THP check
  memcg: page_alloc: skip bulk allocator for __GFP_ACCOUNT
parents f25a5481 9c7516d6
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -1251,7 +1251,7 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
{
	struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
	struct journal_head *jh;
	int ret;
	int ret = 1;

	if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
		return 0;
@@ -1259,6 +1259,8 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
	if (!buffer_jbd(bg_bh))
		return 1;

	jbd_lock_bh_journal_head(bg_bh);
	if (buffer_jbd(bg_bh)) {
		jh = bh2jh(bg_bh);
		spin_lock(&jh->b_state_lock);
		bg = (struct ocfs2_group_desc *) jh->b_committed_data;
@@ -1267,6 +1269,8 @@ static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
		else
			ret = 1;
		spin_unlock(&jh->b_state_lock);
	}
	jbd_unlock_bh_journal_head(bg_bh);

	return ret;
}
+23 −0
Original line number Diff line number Diff line
@@ -171,6 +171,15 @@ enum pageflags {
	/* Compound pages. Stored in first tail page's flags */
	PG_double_map = PG_workingset,

#ifdef CONFIG_MEMORY_FAILURE
	/*
	 * Compound pages. Stored in first tail page's flags.
	 * Indicates that at least one subpage is hwpoisoned in the
	 * THP.
	 */
	PG_has_hwpoisoned = PG_mappedtodisk,
#endif

	/* non-lru isolated movable page */
	PG_isolated = PG_reclaim,

@@ -668,6 +677,20 @@ PAGEFLAG_FALSE(DoubleMap)
	TESTSCFLAG_FALSE(DoubleMap)
#endif

#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE)
/*
 * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the
 * compound page.
 *
 * This flag is set by hwpoison handler.  Cleared by THP split or free page.
 */
PAGEFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
	TESTSCFLAG(HasHWPoisoned, has_hwpoisoned, PF_SECOND)
#else
PAGEFLAG_FALSE(HasHWPoisoned)
	TESTSCFLAG_FALSE(HasHWPoisoned)
#endif

/*
 * Check if a page is currently marked HWPoisoned. Note that this check is
 * best effort only and inherently racy: there is no way to synchronize with
+2 −2
Original line number Diff line number Diff line
@@ -219,14 +219,14 @@ static void damon_test_split_regions_of(struct kunit *test)
	r = damon_new_region(0, 22);
	damon_add_region(r, t);
	damon_split_regions_of(c, t, 2);
	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2u);
	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u);
	damon_free_target(t);

	t = damon_new_target(42);
	r = damon_new_region(0, 220);
	damon_add_region(r, t);
	damon_split_regions_of(c, t, 4);
	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 4u);
	KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
	damon_free_target(t);
	damon_destroy_ctx(c);
}
+2 −0
Original line number Diff line number Diff line
@@ -2426,6 +2426,8 @@ static void __split_huge_page(struct page *page, struct list_head *list,
	/* lock lru list/PageCompound, ref frozen by page_ref_freeze */
	lruvec = lock_page_lruvec(head);

	ClearPageHasHWPoisoned(head);

	for (i = nr - 1; i >= 1; i--) {
		__split_huge_page_tail(head, i, lruvec, list);
		/* Some pages can be beyond EOF: drop them from page cache */
+17 −9
Original line number Diff line number Diff line
@@ -445,22 +445,25 @@ static bool hugepage_vma_check(struct vm_area_struct *vma,
	if (!transhuge_vma_enabled(vma, vm_flags))
		return false;

	if (vma->vm_file && !IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) -
				vma->vm_pgoff, HPAGE_PMD_NR))
		return false;

	/* Enabled via shmem mount options or sysfs settings. */
	if (shmem_file(vma->vm_file) && shmem_huge_enabled(vma)) {
		return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
				HPAGE_PMD_NR);
	}
	if (shmem_file(vma->vm_file))
		return shmem_huge_enabled(vma);

	/* THP settings require madvise. */
	if (!(vm_flags & VM_HUGEPAGE) && !khugepaged_always())
		return false;

	/* Read-only file mappings need to be aligned for THP to work. */
	/* Only regular file is valid */
	if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file &&
	    !inode_is_open_for_write(vma->vm_file->f_inode) &&
	    (vm_flags & VM_EXEC)) {
		return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
				HPAGE_PMD_NR);
		struct inode *inode = vma->vm_file->f_inode;

		return !inode_is_open_for_write(inode) &&
			S_ISREG(inode->i_mode);
	}

	if (!vma->anon_vma || vma->vm_ops)
@@ -1763,6 +1766,10 @@ static void collapse_file(struct mm_struct *mm,
				filemap_flush(mapping);
				result = SCAN_FAIL;
				goto xa_unlocked;
			} else if (PageWriteback(page)) {
				xas_unlock_irq(&xas);
				result = SCAN_FAIL;
				goto xa_unlocked;
			} else if (trylock_page(page)) {
				get_page(page);
				xas_unlock_irq(&xas);
@@ -1798,7 +1805,8 @@ static void collapse_file(struct mm_struct *mm,
			goto out_unlock;
		}

		if (!is_shmem && PageDirty(page)) {
		if (!is_shmem && (PageDirty(page) ||
				  PageWriteback(page))) {
			/*
			 * khugepaged only works on read-only fd, so this
			 * page is dirty because it hasn't been flushed
Loading