Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp269469imm; Mon, 2 Jul 2018 11:11:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIrewl7pXOH8CARRlWBAQTed3fH5EPn5CZbrLTtGcL022ymP3MTrrWZJqndm81ifptd7i15 X-Received: by 2002:a65:5cc5:: with SMTP id b5-v6mr22395884pgt.425.1530555115484; Mon, 02 Jul 2018 11:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530555115; cv=none; d=google.com; s=arc-20160816; b=xrxxjwLaUmmwBqksJfnTXS0ju36fr/4ChhQxI+ugBwVncT97TShivC7CvzOHYyUFMn t+e5UJzoy0TLazAES2PMBVBIj5KFLe7Wy8AHuDZLsjtO2pyr43p14WB87zGiL6r8SAjj TyN7Dek2q8JvJZ4VR9lZlx3ingzSIC6vf4Z6NwjJcDD0GAsPAyTKjdqzTg57PtB9wFwb slpzTuo9TNj0f0SXzHeW/+hVXlhIT9+K2g3phPjN9CS5LYrZrKdss5WUvrfHOgBzC/wh TmNjeYywrQUEaZpYGlblou7eBa4UmhLR7itNyOdn2/ZkwUiGaYcl1CTLNKz7UZI08tXM 3ctA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=uotyYUa3VvEocD+8yXqE6V+kgvG+6XnBkPQosVR572k=; b=hMpVXT+dgfrRYwfQhmf0QalFbJOquLnlXHH4pB7CrukgrW7yz2kSHQk0+ME0W3lLAL OeW0YsFboieIZEhXJmU5KQFY8inYI8zlrsymz5FJ3H2bdYhBCjn2cCyhz9XZQSb5ImXB gPvTX8C3P0JgvhN+OJrnSTTXCgvdssJtCo2pciONn3i5TD6mxHxkzOA0cp61jFIs3VN6 hwlR/BAhXh/stppa0ku/QtUrYl5q2Ev33LO1X71vhChTt63qXBCPKBwoia945BYHv2Kg zhsDDt9MIkARpsMScfcyJzkXIGnHdKLuQQ6tx072ZvQqSb7bAyK4PF/GDvS94N8eu1Ii xJOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b31-v6si1509536pgl.437.2018.07.02.11.11.40; Mon, 02 Jul 2018 11:11:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753040AbeGBSKm (ORCPT + 99 others); Mon, 2 Jul 2018 14:10:42 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:53029 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbeGBSKl (ORCPT ); Mon, 2 Jul 2018 14:10:41 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R791e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0T3r74G1_1530555025; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T3r74G1_1530555025) by smtp.aliyun-inc.com(127.0.0.1); Tue, 03 Jul 2018 02:10:33 +0800 Subject: Re: [RFC v3 PATCH 5/5] x86: check VM_DEAD flag in page fault To: Michal Hocko Cc: Laurent Dufour , willy@infradead.org, akpm@linux-foundation.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, tglx@linutronix.de, hpa@zytor.com, linux-mm@kvack.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <1530311985-31251-1-git-send-email-yang.shi@linux.alibaba.com> <1530311985-31251-6-git-send-email-yang.shi@linux.alibaba.com> <84eba553-2e0b-1a90-d543-6b22c1b3c5f8@linux.vnet.ibm.com> <20180702121528.GM19043@dhcp22.suse.cz> <80406cbd-67f4-ca4c-cd54-aeb305579a72@linux.vnet.ibm.com> <20180702124558.GP19043@dhcp22.suse.cz> <20180702133733.GU19043@dhcp22.suse.cz> <6fd4eb3d-ef66-7a37-4adb-05c22ac51d95@linux.alibaba.com> <20180702175749.GG19043@dhcp22.suse.cz> From: Yang Shi Message-ID: Date: Mon, 2 Jul 2018 11:10:23 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180702175749.GG19043@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/2/18 10:57 AM, Michal Hocko wrote: > On Mon 02-07-18 10:24:27, Yang Shi wrote: >> >> On 7/2/18 6:37 AM, Michal Hocko wrote: >>> On Mon 02-07-18 15:33:11, Laurent Dufour wrote: >>>> On 02/07/2018 14:45, Michal Hocko wrote: >>>>> On Mon 02-07-18 14:26:09, Laurent Dufour wrote: >>>>>> On 02/07/2018 14:15, Michal Hocko wrote: >>> [...] >>>>>>> We already do have a model for that. Have a look at MMF_UNSTABLE. >>>>>> MMF_UNSTABLE is a mm's flag, here this is a VMA's flag which is checked. >>>>> Yeah, and we have the VMA ready for all places where we do check the >>>>> flag. check_stable_address_space can be made to get vma rather than mm. >>>> Yeah, this would have been more efficient to check that flag at the beginning >>>> of the page fault handler rather than the end, but this way it will be easier >>>> to handle the speculative page fault too ;) >>> The thing is that it doesn't really need to be called earlier. You are >>> not risking data corruption on file backed mappings. >> OK, I just think it could save a few cycles to check the flag earlier. > This should be an extremely rare case. Just think about it. It should > only ever happen when an access races with munmap which itself is > questionable if not an outright bug. > >> If nobody think it is necessary, we definitely could re-use >> check_stable_address_space(), > If we really need this whole VM_DEAD thing then it should be better > handled at the same place rather than some ad-hoc places. > >> just return VM_FAULT_SIGSEGV for VM_DEAD vma, >> and check for both shared and non-shared. > Why would you even care about shared mappings? Just thought about we are dealing with VM_DEAD, which means the vma will be tore down soon regardless it is shared or non-shared. MMF_UNSTABLE doesn't care about !shared case.