Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp469018pxv; Wed, 30 Jun 2021 09:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTVSl6vlomZmn/cJMoIpdBtt2pUz5v+wPi/LjHnVgnFt6UnGeEUGPdPufvNPFDATM3NaoF X-Received: by 2002:a92:6705:: with SMTP id b5mr25738118ilc.55.1625071116310; Wed, 30 Jun 2021 09:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625071116; cv=none; d=google.com; s=arc-20160816; b=IB5HBEJr1mh2+NSelEC+5e4mxVI4zXNygXCAnnWT3q73y29OXBQvluTqq0u1CZfDwo OWR1E79gsmsx5mrf4GzTjWj2t4cae74DDPYXNH3YZjbs440wpFxLOO+cnRd2aa0XO9y8 5aekUDk8N+4kDxlfI58C7qsEGns0l6htjC3PdMy4i0Ugn2YKHR4P6UYqteno7RbYsT/U Hwo4+pR4Ae9+0pbJNiL8pnXW19YriqqNhZGtAKrDFggHJ5pux3sSZEUyFsiksjgkqXCt YImBe1YyYuSHZ8NLXtJ9mXg6pydW9A8z+iMNHkWH3FYoLqpTkp0SejIIZHBx6N8SYYuV BURA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8Tv685euhNxcX0iCBCegfs8OeKiXPDy3/j9gU3ONo4Q=; b=b0Iy6VhsP4le8prhsSNeczZ/O9Ojh7KT3R/LTypedoDKQ0WVyHw2tmrqwj0gShviH2 1GaIY/lXwbiMO+SVmntHliyQ8bySYKYvaXYj6P0L+XXHfF0f0a7vMSzC5Uc+SfP+fWk5 sszx5a57QQWMN1zET7VEsxtX3WMbTv6I35BYWVNRkSKLrXcVLlLdgq4MDk27jMonGkhX iNOHq5KUtlKZiwq/5e8KAuV/0qR1848TYBHgGeIQcLcBcEhc/iq6C43g1Zni3Za1hHpe f4Li4JPOdINRPfrYO1XzRXUkYumMRiKWRI6c4Olte7goKz3PLxHd3oqOWSIR0BxULR6z bLPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L4Jdnhk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si21733112ilv.49.2021.06.30.09.38.21; Wed, 30 Jun 2021 09:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L4Jdnhk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbhF3QkH (ORCPT + 99 others); Wed, 30 Jun 2021 12:40:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbhF3QkF (ORCPT ); Wed, 30 Jun 2021 12:40:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6248B6143A; Wed, 30 Jun 2021 16:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625071056; bh=fXFRwwIpr1pkbYhPokSUGN3Kioi8aY6VmPkFSwVxJog=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L4Jdnhk4Ha/SKLA3QfGf/Ztd/pTzVu0TSJf2AFyXtErkqcnJttu6bmA1KPcIbpaTd cdaq1mrUrnSPC+TOn0InKjbA5K3L5xjOIVAsVcbsCJbN1wjZTX+cezHDCERaBHYoY+ svnuN54AXS1vTZX2EldUhCj/HBU5qoGjqCCYoH0EZW0dt6UVsupXdtOgXDeu2iZDF/ 4U8Rvk/NBhzWO5d+dNSNL0ShXypnojVpEB+lCNaJTkXWEj0Z7AOVLaaiBHKu6PZ9sd A8oVUnQDS0PSwOI8ZJQf02dfRPWMAYZSfczkq1QeL8WWlysgYfF5Z10mbyDvBjZaEd ieOyrwz0V0kYA== Date: Wed, 30 Jun 2021 09:37:35 -0700 From: Ming Lin To: Vivek Goyal Cc: Linus Torvalds , Hugh Dickins , Simon Ser , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, virtio-fs-list , "Dr. David Alan Gilbert" , Miklos Szeredi Subject: Re: [PATCH v2 2/2] mm: adds NOSIGBUS extension to mmap() Message-ID: <20210630163735.GA289024@ubuntu-server> References: <1622792602-40459-1-git-send-email-mlin@kernel.org> <1622792602-40459-3-git-send-email-mlin@kernel.org> <20210628142723.GB1803896@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210628142723.GB1803896@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org O Mon, Jun 28, 2021 at 10:27:23AM -0400, Vivek Goyal wrote: > On Fri, Jun 04, 2021 at 12:43:22AM -0700, Ming Lin wrote: > > Adds new flag MAP_NOSIGBUS of mmap() to specify the behavior of > > "don't SIGBUS on fault". Right now, this flag is only allowed > > for private mapping. > > > > For MAP_NOSIGBUS mapping, map in the zero page on read fault > > or fill a freshly allocated page with zeroes on write fault. > > I am wondering if this could be of limited use for me if MAP_NOSIGBUS > were to be supported for shared mappings as well. V1 did support shared mapping. https://lkml.org/lkml/2021/6/1/1078 And V0 even supported unmapping the zero page for later write. https://github.com/minggr/linux/commit/77f3722b94ff33cafe0a72c1bf1b8fa374adb29f We may support shared mapping if there is a real use case. As Hugh mentioned: > And by restricting to MAP_PRIVATE, you would allow for adding a > proper MAP_SHARED implementation later, if it's thought useful > (that being the implementation which can subsequently unmap a > zero page to let new page cache be mapped). See https://lkml.org/lkml/2021/6/1/1258 Ming > > When virtiofs is run with dax enabled, then it is possible that if > a file is shared between two guests, then one guest truncates the > file and second guest tries to do load/store operation. Given current > kvm architecture, there is no mechanism to propagate SIGBUS to guest > process, instead KVM retries page fault infinitely and guest cpu/process > hangs. > > Ideally we want this error to propagate all the way back into the > guest and to the guest process but that solution is not in place yet. > > https://lore.kernel.org/kvm/20200406190951.GA19259@redhat.com/ > > In the absense of a proper solution, one could think of mapping > shared file on host with MAP_NOSIGBUS, and hopefully that means > kvm will be able to resolve fault to a zero filled page and guest > will not hang. But this means that data sharing between two processes > is now broken. Writes by process A will not be visible to process B > in another once this situation happens, IIUC. > > So if we were to MAP_NOSIGBUS, guest will not hang but failures resulting > from ftruncate will be silent and will be noticed sometime later. I guess > not exactly a very pleasant scenario... > > Thanks > Vivek