Skip to content

Commit e5220dd

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "13 patches. Subsystems affected by this patch series: mips, mm (kfence, debug, pagealloc, memory-hotplug, hugetlb, kasan, and hugetlb), init, proc, lib, ocfs2, and mailmap" * emailed patches from Andrew Morton <[email protected]>: mailmap: use private address for Michel Lespinasse ocfs2: fix data corruption by fallocate lib: crc64: fix kernel-doc warning mm, hugetlb: fix simple resv_huge_pages underflow on UFFDIO_COPY mm/kasan/init.c: fix doc warning proc: add .gitignore for proc-subset-pid selftest hugetlb: pass head page to remove_hugetlb_page() drivers/base/memory: fix trying offlining memory blocks with memory holes on aarch64 mm/page_alloc: fix counting of free pages after take off from buddy mm/debug_vm_pgtable: fix alignment for pmd/pud_advanced_tests() pid: take a reference when initializing `cad_pid` kfence: use TASK_IDLE when awaiting allocation Revert "MIPS: make userspace mapping young by default"
2 parents af8d9eb + 2eff057 commit e5220dd

File tree

14 files changed

+107
-36
lines changed

14 files changed

+107
-36
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ Maxime Ripard <[email protected]> <[email protected]>
243243
Mayuresh Janorkar <[email protected]>
244244
Michael Buesch <[email protected]>
245245
Michel Dänzer <[email protected]>
246+
Michel Lespinasse <[email protected]>
247+
248+
246249
247250
248251

arch/mips/mm/cache.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,31 +158,29 @@ unsigned long _page_cachable_default;
158158
EXPORT_SYMBOL(_page_cachable_default);
159159

160160
#define PM(p) __pgprot(_page_cachable_default | (p))
161-
#define PVA(p) PM(_PAGE_VALID | _PAGE_ACCESSED | (p))
162161

163162
static inline void setup_protection_map(void)
164163
{
165164
protection_map[0] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
166-
protection_map[1] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC);
167-
protection_map[2] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
168-
protection_map[3] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC);
169-
protection_map[4] = PVA(_PAGE_PRESENT);
170-
protection_map[5] = PVA(_PAGE_PRESENT);
171-
protection_map[6] = PVA(_PAGE_PRESENT);
172-
protection_map[7] = PVA(_PAGE_PRESENT);
165+
protection_map[1] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC);
166+
protection_map[2] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
167+
protection_map[3] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC);
168+
protection_map[4] = PM(_PAGE_PRESENT);
169+
protection_map[5] = PM(_PAGE_PRESENT);
170+
protection_map[6] = PM(_PAGE_PRESENT);
171+
protection_map[7] = PM(_PAGE_PRESENT);
173172

174173
protection_map[8] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ);
175-
protection_map[9] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC);
176-
protection_map[10] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE |
174+
protection_map[9] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC);
175+
protection_map[10] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE |
177176
_PAGE_NO_READ);
178-
protection_map[11] = PVA(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE);
179-
protection_map[12] = PVA(_PAGE_PRESENT);
180-
protection_map[13] = PVA(_PAGE_PRESENT);
181-
protection_map[14] = PVA(_PAGE_PRESENT);
182-
protection_map[15] = PVA(_PAGE_PRESENT);
177+
protection_map[11] = PM(_PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE);
178+
protection_map[12] = PM(_PAGE_PRESENT);
179+
protection_map[13] = PM(_PAGE_PRESENT);
180+
protection_map[14] = PM(_PAGE_PRESENT | _PAGE_WRITE);
181+
protection_map[15] = PM(_PAGE_PRESENT | _PAGE_WRITE);
183182
}
184183

185-
#undef _PVA
186184
#undef PM
187185

188186
void cpu_cache_init(void)

drivers/base/memory.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,14 @@ static int memory_block_offline(struct memory_block *mem)
218218
struct zone *zone;
219219
int ret;
220220

221-
zone = page_zone(pfn_to_page(start_pfn));
222-
223221
/*
224222
* Unaccount before offlining, such that unpopulated zone and kthreads
225223
* can properly be torn down in offline_pages().
226224
*/
227-
if (nr_vmemmap_pages)
225+
if (nr_vmemmap_pages) {
226+
zone = page_zone(pfn_to_page(start_pfn));
228227
adjust_present_page_count(zone, -nr_vmemmap_pages);
228+
}
229229

230230
ret = offline_pages(start_pfn + nr_vmemmap_pages,
231231
nr_pages - nr_vmemmap_pages);

fs/ocfs2/file.c

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,45 @@ int ocfs2_remove_inode_range(struct inode *inode,
18551855
return ret;
18561856
}
18571857

1858+
/*
1859+
* zero out partial blocks of one cluster.
1860+
*
1861+
* start: file offset where zero starts, will be made upper block aligned.
1862+
* len: it will be trimmed to the end of current cluster if "start + len"
1863+
* is bigger than it.
1864+
*/
1865+
static int ocfs2_zeroout_partial_cluster(struct inode *inode,
1866+
u64 start, u64 len)
1867+
{
1868+
int ret;
1869+
u64 start_block, end_block, nr_blocks;
1870+
u64 p_block, offset;
1871+
u32 cluster, p_cluster, nr_clusters;
1872+
struct super_block *sb = inode->i_sb;
1873+
u64 end = ocfs2_align_bytes_to_clusters(sb, start);
1874+
1875+
if (start + len < end)
1876+
end = start + len;
1877+
1878+
start_block = ocfs2_blocks_for_bytes(sb, start);
1879+
end_block = ocfs2_blocks_for_bytes(sb, end);
1880+
nr_blocks = end_block - start_block;
1881+
if (!nr_blocks)
1882+
return 0;
1883+
1884+
cluster = ocfs2_bytes_to_clusters(sb, start);
1885+
ret = ocfs2_get_clusters(inode, cluster, &p_cluster,
1886+
&nr_clusters, NULL);
1887+
if (ret)
1888+
return ret;
1889+
if (!p_cluster)
1890+
return 0;
1891+
1892+
offset = start_block - ocfs2_clusters_to_blocks(sb, cluster);
1893+
p_block = ocfs2_clusters_to_blocks(sb, p_cluster) + offset;
1894+
return sb_issue_zeroout(sb, p_block, nr_blocks, GFP_NOFS);
1895+
}
1896+
18581897
/*
18591898
* Parts of this function taken from xfs_change_file_space()
18601899
*/
@@ -1865,7 +1904,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
18651904
{
18661905
int ret;
18671906
s64 llen;
1868-
loff_t size;
1907+
loff_t size, orig_isize;
18691908
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
18701909
struct buffer_head *di_bh = NULL;
18711910
handle_t *handle;
@@ -1896,14 +1935,15 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
18961935
goto out_inode_unlock;
18971936
}
18981937

1938+
orig_isize = i_size_read(inode);
18991939
switch (sr->l_whence) {
19001940
case 0: /*SEEK_SET*/
19011941
break;
19021942
case 1: /*SEEK_CUR*/
19031943
sr->l_start += f_pos;
19041944
break;
19051945
case 2: /*SEEK_END*/
1906-
sr->l_start += i_size_read(inode);
1946+
sr->l_start += orig_isize;
19071947
break;
19081948
default:
19091949
ret = -EINVAL;
@@ -1957,6 +1997,14 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
19571997
default:
19581998
ret = -EINVAL;
19591999
}
2000+
2001+
/* zeroout eof blocks in the cluster. */
2002+
if (!ret && change_size && orig_isize < size) {
2003+
ret = ocfs2_zeroout_partial_cluster(inode, orig_isize,
2004+
size - orig_isize);
2005+
if (!ret)
2006+
i_size_write(inode, size);
2007+
}
19602008
up_write(&OCFS2_I(inode)->ip_alloc_sem);
19612009
if (ret) {
19622010
mlog_errno(ret);
@@ -1973,9 +2021,6 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
19732021
goto out_inode_unlock;
19742022
}
19752023

1976-
if (change_size && i_size_read(inode) < size)
1977-
i_size_write(inode, size);
1978-
19792024
inode->i_ctime = inode->i_mtime = current_time(inode);
19802025
ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
19812026
if (ret < 0)

include/linux/pgtable.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
432432
* To be differentiate with macro pte_mkyoung, this macro is used on platforms
433433
* where software maintains page access bit.
434434
*/
435+
#ifndef pte_sw_mkyoung
436+
static inline pte_t pte_sw_mkyoung(pte_t pte)
437+
{
438+
return pte;
439+
}
440+
#define pte_sw_mkyoung pte_sw_mkyoung
441+
#endif
442+
435443
#ifndef pte_savedwrite
436444
#define pte_savedwrite pte_write
437445
#endif

init/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ static noinline void __init kernel_init_freeable(void)
15371537
*/
15381538
set_mems_allowed(node_states[N_MEMORY]);
15391539

1540-
cad_pid = task_pid(current);
1540+
cad_pid = get_pid(task_pid(current));
15411541

15421542
smp_prepare_cpus(setup_max_cpus);
15431543

lib/crc64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ MODULE_LICENSE("GPL v2");
3737
/**
3838
* crc64_be - Calculate bitwise big-endian ECMA-182 CRC64
3939
* @crc: seed value for computation. 0 or (u64)~0 for a new CRC calculation,
40-
or the previous crc64 value if computing incrementally.
40+
* or the previous crc64 value if computing incrementally.
4141
* @p: pointer to buffer over which CRC64 is run
4242
* @len: length of buffer @p
4343
*/

mm/debug_vm_pgtable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static void __init pmd_advanced_tests(struct mm_struct *mm,
192192

193193
pr_debug("Validating PMD advanced\n");
194194
/* Align the address wrt HPAGE_PMD_SIZE */
195-
vaddr = (vaddr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE;
195+
vaddr &= HPAGE_PMD_MASK;
196196

197197
pgtable_trans_huge_deposit(mm, pmdp, pgtable);
198198

@@ -330,7 +330,7 @@ static void __init pud_advanced_tests(struct mm_struct *mm,
330330

331331
pr_debug("Validating PUD advanced\n");
332332
/* Align the address wrt HPAGE_PUD_SIZE */
333-
vaddr = (vaddr & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE;
333+
vaddr &= HPAGE_PUD_MASK;
334334

335335
set_pud_at(mm, vaddr, pudp, pud);
336336
pudp_set_wrprotect(mm, vaddr, pudp);

mm/hugetlb.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ int dissolve_free_huge_page(struct page *page)
17931793
SetPageHWPoison(page);
17941794
ClearPageHWPoison(head);
17951795
}
1796-
remove_hugetlb_page(h, page, false);
1796+
remove_hugetlb_page(h, head, false);
17971797
h->max_huge_pages--;
17981798
spin_unlock_irq(&hugetlb_lock);
17991799
update_and_free_page(h, head);
@@ -4889,10 +4889,20 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
48894889
if (!page)
48904890
goto out;
48914891
} else if (!*pagep) {
4892-
ret = -ENOMEM;
4892+
/* If a page already exists, then it's UFFDIO_COPY for
4893+
* a non-missing case. Return -EEXIST.
4894+
*/
4895+
if (vm_shared &&
4896+
hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) {
4897+
ret = -EEXIST;
4898+
goto out;
4899+
}
4900+
48934901
page = alloc_huge_page(dst_vma, dst_addr, 0);
4894-
if (IS_ERR(page))
4902+
if (IS_ERR(page)) {
4903+
ret = -ENOMEM;
48954904
goto out;
4905+
}
48964906

48974907
ret = copy_huge_page_from_user(page,
48984908
(const void __user *) src_addr,

mm/kasan/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ static int __ref zero_p4d_populate(pgd_t *pgd, unsigned long addr,
220220
/**
221221
* kasan_populate_early_shadow - populate shadow memory region with
222222
* kasan_early_shadow_page
223-
* @shadow_start - start of the memory range to populate
224-
* @shadow_end - end of the memory range to populate
223+
* @shadow_start: start of the memory range to populate
224+
* @shadow_end: end of the memory range to populate
225225
*/
226226
int __ref kasan_populate_early_shadow(const void *shadow_start,
227227
const void *shadow_end)

0 commit comments

Comments
 (0)