Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp257060imm; Mon, 2 Jul 2018 10:59:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIGZpacxBPvIWuqTA/Vo1fZrxqWZl9oMmPADkJDuQt8KDvoFv7LK7HDkQmiS+zBK85sFh4+ X-Received: by 2002:a17:902:7d82:: with SMTP id a2-v6mr26808726plm.202.1530554373049; Mon, 02 Jul 2018 10:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530554373; cv=none; d=google.com; s=arc-20160816; b=SjbQSzGJlRJD4AWqCNSPf5eWv5//5ubJuDHbL7yFlGLcquchAcWswPFdNpPQvdMwW2 80gRLY5DNW+un0kZhs6bmfXAq1e8BlYC3JLr52TuUpAEQvbigypZPGD0fLefC034LUkU 4iZLRmltawCS85g+zPozMw9r4mLeAUcmhYyxhrlXf03D1uhu6XOnx/+J+FGI3ACC9I3s +YlkNoyNN46hcC0iGk4O/5zbqUq2v+AicWrr9pS2zF/V7IJqkEXw8TA8o3bLQAIY6HSg DhcX2v77InK9nuzkYG/BAzk6s2rXYj1i+SkVArMh8V0Zz9iOlm/A6ny5+oW6W6XQ8OFJ 23Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=IwGL30NjWxFg2+q58lYohMmGMCBOzth1xd0I/7rwZdA=; b=SemuFEZQ+HtmksONTFQmPVY168PkFOhRcUJ+7WDT9WxAI1gQ+M0JZg90zgbHtEhFGJ hcTikRUPRTDpJ50mGFLUOd5nzoeIYMDdJrqAxPAHEiOSkB16W9G7vrAbvLquZ6bROoq0 hEXQonKU/Vjl27gLXMSjfCvaB4FHrxDHbXtheBM6bUWwIvBRc2Y80BGO0EKnFeM/L3sc 77azaNeY/FjrtZFpe29aU5duWwApksWLWpXR/vw1EPJhrRtVagmB0NxYk5K7XA9ubCj8 dn+kOnoIdDDkVXBWAPuAWmWZIkNB2oSQnBxTqLpSaZoagJ11YubwmL0Xaqw14aL3N1wR rNeA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6-v6si16337587plv.315.2018.07.02.10.59.18; Mon, 02 Jul 2018 10:59:33 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753254AbeGBR5x (ORCPT + 99 others); Mon, 2 Jul 2018 13:57:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:49276 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752606AbeGBR5w (ORCPT ); Mon, 2 Jul 2018 13:57:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B68FBADB8; Mon, 2 Jul 2018 17:57:50 +0000 (UTC) Date: Mon, 2 Jul 2018 19:57:49 +0200 From: Michal Hocko To: Yang Shi 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 Subject: Re: [RFC v3 PATCH 5/5] x86: check VM_DEAD flag in page fault Message-ID: <20180702175749.GG19043@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fd4eb3d-ef66-7a37-4adb-05c22ac51d95@linux.alibaba.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Michal Hocko SUSE Labs