get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/811789/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 811789,
    "url": "http://patchwork.ozlabs.org/api/patches/811789/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504894024-2750-8-git-send-email-ldufour@linux.vnet.ibm.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<1504894024-2750-8-git-send-email-ldufour@linux.vnet.ibm.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1504894024-2750-8-git-send-email-ldufour@linux.vnet.ibm.com/",
    "date": "2017-09-08T18:06:51",
    "name": "[v3,07/20] mm: Cache some VMA fields in the vm_fault structure",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "10fe4703e588a99766d95663161946b2147f673c",
    "submitter": {
        "id": 40248,
        "url": "http://patchwork.ozlabs.org/api/people/40248/?format=api",
        "name": "Laurent Dufour",
        "email": "ldufour@linux.vnet.ibm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504894024-2750-8-git-send-email-ldufour@linux.vnet.ibm.com/mbox/",
    "series": [
        {
            "id": 2269,
            "url": "http://patchwork.ozlabs.org/api/series/2269/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=2269",
            "date": "2017-09-08T18:06:44",
            "name": "Speculative page faults",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/2269/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/811789/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/811789/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpm810Npkz9s7C\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 04:29:53 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xpm804ZVDzDqY8\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 04:29:52 +1000 (AEST)",
            "from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n\t[148.163.158.5])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xplfN21yQzDrWS\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat,  9 Sep 2017 04:07:39 +1000 (AEST)",
            "from pps.filterd (m0098413.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv88I4Xpb056552\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 8 Sep 2017 14:07:37 -0400",
            "from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2cuw4n1aed-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 08 Sep 2017 14:07:36 -0400",
            "from localhost\n\tby e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from <ldufour@linux.vnet.ibm.com>;\n\tFri, 8 Sep 2017 19:07:34 +0100",
            "from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195)\n\tby e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tFri, 8 Sep 2017 19:07:29 +0100",
            "from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60])\n\tby b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v88I7TVa29032614; Fri, 8 Sep 2017 18:07:29 GMT",
            "from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 673AE42041;\n\tFri,  8 Sep 2017 19:03:56 +0100 (BST)",
            "from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id C72A44203F;\n\tFri,  8 Sep 2017 19:03:53 +0100 (BST)",
            "from nimbus.lab.toulouse-stg.fr.ibm.com (unknown [9.145.31.125])\n\tby d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP;\n\tFri,  8 Sep 2017 19:03:53 +0100 (BST)"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com\n\t(client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com;\n\tenvelope-from=ldufour@linux.vnet.ibm.com; receiver=<UNKNOWN>)",
        "From": "Laurent Dufour <ldufour@linux.vnet.ibm.com>",
        "To": "paulmck@linux.vnet.ibm.com, peterz@infradead.org,\n\takpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, \n\tmhocko@kernel.org, dave@stgolabs.net, jack@suse.cz,\n\tMatthew Wilcox <willy@infradead.org>, benh@kernel.crashing.org,\n\tmpe@ellerman.id.au, paulus@samba.org,\n\tThomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, \n\thpa@zytor.com, Will Deacon <will.deacon@arm.com>,\n\tSergey Senozhatsky <sergey.senozhatsky@gmail.com>",
        "Subject": "[PATCH v3 07/20] mm: Cache some VMA fields in the vm_fault structure",
        "Date": "Fri,  8 Sep 2017 20:06:51 +0200",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1504894024-2750-1-git-send-email-ldufour@linux.vnet.ibm.com>",
        "References": "<1504894024-2750-1-git-send-email-ldufour@linux.vnet.ibm.com>",
        "X-TM-AS-GCONF": "00",
        "x-cbid": "17090818-0008-0000-0000-000004959E5E",
        "X-IBM-AV-DETECTION": "SAVI=unused REMOTE=unused XFE=unused",
        "x-cbparentid": "17090818-0009-0000-0000-00001E26A5EF",
        "Message-Id": "<1504894024-2750-8-git-send-email-ldufour@linux.vnet.ibm.com>",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-08_12:, , signatures=0",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=2\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709080270",
        "X-BeenThere": "linuxppc-dev@lists.ozlabs.org",
        "X-Mailman-Version": "2.1.23",
        "Precedence": "list",
        "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>",
        "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>",
        "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>",
        "Cc": "linuxppc-dev@lists.ozlabs.org, x86@kernel.org,\n\tlinux-kernel@vger.kernel.org, npiggin@gmail.com, linux-mm@kvack.org,\n\tTim Chen <tim.c.chen@linux.intel.com>, \n\tharen@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com",
        "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org",
        "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"
    },
    "content": "When handling speculative page fault, the vma->vm_flags and\nvma->vm_page_prot fields are read once the page table lock is released. So\nthere is no more guarantee that these fields would not change in our back.\nThey will be saved in the vm_fault structure before the VMA is checked for\nchanges.\n\nThis patch also set the fields in hugetlb_no_page() and\n__collapse_huge_page_swapin even if it is not need for the callee.\n\nSigned-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>\n---\n include/linux/mm.h |  6 ++++++\n mm/hugetlb.c       |  2 ++\n mm/khugepaged.c    |  2 ++\n mm/memory.c        | 38 ++++++++++++++++++++------------------\n 4 files changed, 30 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/include/linux/mm.h b/include/linux/mm.h\nindex 46e769a5a7ab..5fd90ac31317 100644\n--- a/include/linux/mm.h\n+++ b/include/linux/mm.h\n@@ -350,6 +350,12 @@ struct vm_fault {\n \t\t\t\t\t * page table to avoid allocation from\n \t\t\t\t\t * atomic context.\n \t\t\t\t\t */\n+\t/*\n+\t * These entries are required when handling speculative page fault.\n+\t * This way the page handling is done using consistent field values.\n+\t */\n+\tunsigned long vma_flags;\n+\tpgprot_t vma_page_prot;\n };\n \n /* page entry size for vm->huge_fault() */\ndiff --git a/mm/hugetlb.c b/mm/hugetlb.c\nindex 424b0ef08a60..da82a86a4761 100644\n--- a/mm/hugetlb.c\n+++ b/mm/hugetlb.c\n@@ -3683,6 +3683,8 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,\n \t\t\t\t.vma = vma,\n \t\t\t\t.address = address,\n \t\t\t\t.flags = flags,\n+\t\t\t\t.vma_flags = vma->vm_flags,\n+\t\t\t\t.vma_page_prot = vma->vm_page_prot,\n \t\t\t\t/*\n \t\t\t\t * Hard to debug if it ends up being\n \t\t\t\t * used by a callee that assumes\ndiff --git a/mm/khugepaged.c b/mm/khugepaged.c\nindex 56dd994c05d0..0525a0e74535 100644\n--- a/mm/khugepaged.c\n+++ b/mm/khugepaged.c\n@@ -881,6 +881,8 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,\n \t\t.flags = FAULT_FLAG_ALLOW_RETRY,\n \t\t.pmd = pmd,\n \t\t.pgoff = linear_page_index(vma, address),\n+\t\t.vma_flags = vma->vm_flags,\n+\t\t.vma_page_prot = vma->vm_page_prot,\n \t};\n \n \t/* we only decide to swapin, if there is enough young ptes */\ndiff --git a/mm/memory.c b/mm/memory.c\nindex f250e7c92948..f008042ab24e 100644\n--- a/mm/memory.c\n+++ b/mm/memory.c\n@@ -2556,7 +2556,7 @@ static int wp_page_copy(struct vm_fault *vmf)\n \t\t * Don't let another task, with possibly unlocked vma,\n \t\t * keep the mlocked page.\n \t\t */\n-\t\tif (page_copied && (vma->vm_flags & VM_LOCKED)) {\n+\t\tif (page_copied && (vmf->vma_flags & VM_LOCKED)) {\n \t\t\tlock_page(old_page);\t/* LRU manipulation */\n \t\t\tif (PageMlocked(old_page))\n \t\t\t\tmunlock_vma_page(old_page);\n@@ -2590,7 +2590,7 @@ static int wp_page_copy(struct vm_fault *vmf)\n  */\n int finish_mkwrite_fault(struct vm_fault *vmf)\n {\n-\tWARN_ON_ONCE(!(vmf->vma->vm_flags & VM_SHARED));\n+\tWARN_ON_ONCE(!(vmf->vma_flags & VM_SHARED));\n \tif (!pte_map_lock(vmf))\n \t\treturn VM_FAULT_RETRY;\n \t/*\n@@ -2692,7 +2692,7 @@ static int do_wp_page(struct vm_fault *vmf)\n \t\t * We should not cow pages in a shared writeable mapping.\n \t\t * Just mark the pages writable and/or call ops->pfn_mkwrite.\n \t\t */\n-\t\tif ((vma->vm_flags & (VM_WRITE|VM_SHARED)) ==\n+\t\tif ((vmf->vma_flags & (VM_WRITE|VM_SHARED)) ==\n \t\t\t\t     (VM_WRITE|VM_SHARED))\n \t\t\treturn wp_pfn_shared(vmf);\n \n@@ -2739,7 +2739,7 @@ static int do_wp_page(struct vm_fault *vmf)\n \t\t\treturn VM_FAULT_WRITE;\n \t\t}\n \t\tunlock_page(vmf->page);\n-\t} else if (unlikely((vma->vm_flags & (VM_WRITE|VM_SHARED)) ==\n+\t} else if (unlikely((vmf->vma_flags & (VM_WRITE|VM_SHARED)) ==\n \t\t\t\t\t(VM_WRITE|VM_SHARED))) {\n \t\treturn wp_page_shared(vmf);\n \t}\n@@ -2975,7 +2975,7 @@ int do_swap_page(struct vm_fault *vmf)\n \n \tinc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);\n \tdec_mm_counter_fast(vma->vm_mm, MM_SWAPENTS);\n-\tpte = mk_pte(page, vma->vm_page_prot);\n+\tpte = mk_pte(page, vmf->vma_page_prot);\n \tif ((vmf->flags & FAULT_FLAG_WRITE) && reuse_swap_page(page, NULL)) {\n \t\tpte = maybe_mkwrite(pte_mkdirty(pte), vma);\n \t\tvmf->flags &= ~FAULT_FLAG_WRITE;\n@@ -2999,7 +2999,7 @@ int do_swap_page(struct vm_fault *vmf)\n \n \tswap_free(entry);\n \tif (mem_cgroup_swap_full(page) ||\n-\t    (vma->vm_flags & VM_LOCKED) || PageMlocked(page))\n+\t    (vmf->vma_flags & VM_LOCKED) || PageMlocked(page))\n \t\ttry_to_free_swap(page);\n \tunlock_page(page);\n \tif (page != swapcache) {\n@@ -3056,7 +3056,7 @@ static int do_anonymous_page(struct vm_fault *vmf)\n \tpte_t entry;\n \n \t/* File mapping without ->vm_ops ? */\n-\tif (vma->vm_flags & VM_SHARED)\n+\tif (vmf->vma_flags & VM_SHARED)\n \t\treturn VM_FAULT_SIGBUS;\n \n \t/*\n@@ -3080,7 +3080,7 @@ static int do_anonymous_page(struct vm_fault *vmf)\n \tif (!(vmf->flags & FAULT_FLAG_WRITE) &&\n \t\t\t!mm_forbids_zeropage(vma->vm_mm)) {\n \t\tentry = pte_mkspecial(pfn_pte(my_zero_pfn(vmf->address),\n-\t\t\t\t\t\tvma->vm_page_prot));\n+\t\t\t\t\t\tvmf->vma_page_prot));\n \t\tif (!pte_map_lock(vmf))\n \t\t\treturn VM_FAULT_RETRY;\n \t\tif (!pte_none(*vmf->pte))\n@@ -3113,8 +3113,8 @@ static int do_anonymous_page(struct vm_fault *vmf)\n \t */\n \t__SetPageUptodate(page);\n \n-\tentry = mk_pte(page, vma->vm_page_prot);\n-\tif (vma->vm_flags & VM_WRITE)\n+\tentry = mk_pte(page, vmf->vma_page_prot);\n+\tif (vmf->vma_flags & VM_WRITE)\n \t\tentry = pte_mkwrite(pte_mkdirty(entry));\n \n \tif (!pte_map_lock(vmf)) {\n@@ -3310,7 +3310,7 @@ static int do_set_pmd(struct vm_fault *vmf, struct page *page)\n \tfor (i = 0; i < HPAGE_PMD_NR; i++)\n \t\tflush_icache_page(vma, page + i);\n \n-\tentry = mk_huge_pmd(page, vma->vm_page_prot);\n+\tentry = mk_huge_pmd(page, vmf->vma_page_prot);\n \tif (write)\n \t\tentry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);\n \n@@ -3384,11 +3384,11 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,\n \t\treturn VM_FAULT_NOPAGE;\n \n \tflush_icache_page(vma, page);\n-\tentry = mk_pte(page, vma->vm_page_prot);\n+\tentry = mk_pte(page, vmf->vma_page_prot);\n \tif (write)\n \t\tentry = maybe_mkwrite(pte_mkdirty(entry), vma);\n \t/* copy-on-write page */\n-\tif (write && !(vma->vm_flags & VM_SHARED)) {\n+\tif (write && !(vmf->vma_flags & VM_SHARED)) {\n \t\tinc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);\n \t\tpage_add_new_anon_rmap(page, vma, vmf->address, false);\n \t\tmem_cgroup_commit_charge(page, memcg, false, false);\n@@ -3427,7 +3427,7 @@ int finish_fault(struct vm_fault *vmf)\n \n \t/* Did we COW the page? */\n \tif ((vmf->flags & FAULT_FLAG_WRITE) &&\n-\t    !(vmf->vma->vm_flags & VM_SHARED))\n+\t    !(vmf->vma_flags & VM_SHARED))\n \t\tpage = vmf->cow_page;\n \telse\n \t\tpage = vmf->page;\n@@ -3681,7 +3681,7 @@ static int do_fault(struct vm_fault *vmf)\n \t\tret = VM_FAULT_SIGBUS;\n \telse if (!(vmf->flags & FAULT_FLAG_WRITE))\n \t\tret = do_read_fault(vmf);\n-\telse if (!(vma->vm_flags & VM_SHARED))\n+\telse if (!(vmf->vma_flags & VM_SHARED))\n \t\tret = do_cow_fault(vmf);\n \telse\n \t\tret = do_shared_fault(vmf);\n@@ -3738,7 +3738,7 @@ static int do_numa_page(struct vm_fault *vmf)\n \t * accessible ptes, some can allow access by kernel mode.\n \t */\n \tpte = ptep_modify_prot_start(vma->vm_mm, vmf->address, vmf->pte);\n-\tpte = pte_modify(pte, vma->vm_page_prot);\n+\tpte = pte_modify(pte, vmf->vma_page_prot);\n \tpte = pte_mkyoung(pte);\n \tif (was_writable)\n \t\tpte = pte_mkwrite(pte);\n@@ -3772,7 +3772,7 @@ static int do_numa_page(struct vm_fault *vmf)\n \t * Flag if the page is shared between multiple address spaces. This\n \t * is later used when determining whether to group tasks together\n \t */\n-\tif (page_mapcount(page) > 1 && (vma->vm_flags & VM_SHARED))\n+\tif (page_mapcount(page) > 1 && (vmf->vma_flags & VM_SHARED))\n \t\tflags |= TNF_SHARED;\n \n \tlast_cpupid = page_cpupid_last(page);\n@@ -3816,7 +3816,7 @@ static int wp_huge_pmd(struct vm_fault *vmf, pmd_t orig_pmd)\n \t\treturn vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PMD);\n \n \t/* COW handled on pte level: split pmd */\n-\tVM_BUG_ON_VMA(vmf->vma->vm_flags & VM_SHARED, vmf->vma);\n+\tVM_BUG_ON_VMA(vmf->vma_flags & VM_SHARED, vmf->vma);\n \t__split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL);\n \n \treturn VM_FAULT_FALLBACK;\n@@ -3963,6 +3963,8 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,\n \t\t.flags = flags,\n \t\t.pgoff = linear_page_index(vma, address),\n \t\t.gfp_mask = __get_fault_gfp_mask(vma),\n+\t\t.vma_flags = vma->vm_flags,\n+\t\t.vma_page_prot = vma->vm_page_prot,\n \t};\n \tunsigned int dirty = flags & FAULT_FLAG_WRITE;\n \tstruct mm_struct *mm = vma->vm_mm;\n",
    "prefixes": [
        "v3",
        "07/20"
    ]
}