From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbdAaSAX (ORCPT ); Tue, 31 Jan 2017 13:00:23 -0500 Received: from mga09.intel.com ([134.134.136.24]:20252 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbdAaSAO (ORCPT ); Tue, 31 Jan 2017 13:00:14 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,315,1477983600"; d="scan'208";a="37869059" Subject: Re: [RFC V2 11/12] mm: Tag VMA with VM_CDM flag during page fault To: Anshuman Khandual , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20170130033602.12275-1-khandual@linux.vnet.ibm.com> <20170130033602.12275-12-khandual@linux.vnet.ibm.com> <5f1ec7f6-16d3-8653-4494-50e124916a9e@intel.com> <01ed36eb-bb1d-bb75-57f9-90159985e75e@linux.vnet.ibm.com> Cc: mhocko@suse.com, vbabka@suse.cz, mgorman@suse.de, minchan@kernel.org, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, srikar@linux.vnet.ibm.com, haren@linux.vnet.ibm.com, jglisse@redhat.com, dan.j.williams@intel.com From: Dave Hansen Message-ID: Date: Tue, 31 Jan 2017 09:54:02 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <01ed36eb-bb1d-bb75-57f9-90159985e75e@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/30/2017 09:10 PM, Anshuman Khandual wrote: >> This is happening with mmap_sem held for read. Correct? Is it OK that >> you're modifying the VMA? That vm_flags manipulation is non-atomic, so >> how can that even be safe? > Hmm. should it be done with mmap_sem being held for write. Will look > into this further. But intercepting the page faults inside alloc_pages_vma() > for tagging the VMA is okay from over all design perspective ?. Or this > should be moved up or down the call chain in the page fault path ? Doing it in the fault path seems wrong to me. Apps have to take *explicit* action to go and get access to device memory. It seems like we should mark the VMA *then*, at the time of the explicit action. I also think _implying_ that we want KSM, etc... turned off just because of the target of an mbind() is a bad idea. Apps have to ask for this stuff *explicitly*, so why not also have them turn KSM off explicitly?