Sometimes, an user process incurs writes on file pages
which has VM_DENYWRITE flag in its vma->vm_flags (of
course, the vma has VM_WRITE flags too). In this case,
the kernel creates a new page by a COW fault, but it is
an unexpected behaviour for 64KB file hugepages.
This patch disallows scanning of read-write file pages
to prevent unexpected buggy behaviours.
Change-Id: I28c1da7f7ad4be55be5607316b29a2978896fcb9
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
{
/* Read-only file mappings need to be aligned for THP to work. */
if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file &&
- (vm_flags & VM_DENYWRITE)) {
+ (vm_flags & VM_DENYWRITE) && !(vm_flags & VM_WRITE)) {
return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
nr_pages);
}
return true;
/* Read-only file mappings need to be aligned for THP to work. */
else if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file &&
- (vm_flags & VM_DENYWRITE)) {
+ (vm_flags & VM_DENYWRITE) && !(vm_flags & VM_WRITE)) {
return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff,
HPAGE_PMD_NR);
}