Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2295500rbb; Tue, 27 Feb 2024 18:19:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXGMwyT4ngoxJwAd8gw8Tz/Ukq9forcADwvBWouU27KfxzBAr0P4qNo5sXoI7rdWQDPFZymmax/Dwy3GUwJxnY9xBhR1XNjbFwHs8Bj0Q== X-Google-Smtp-Source: AGHT+IEbdK74Vj5YuhI7sHYn27GBkXRKMj0u881hAmccgvwqCmRf8RMq48UaAaMEpMaEweiByRZk X-Received: by 2002:a9d:674d:0:b0:6e4:b706:9d73 with SMTP id w13-20020a9d674d000000b006e4b7069d73mr414555otm.7.1709086745402; Tue, 27 Feb 2024 18:19:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709086745; cv=pass; d=google.com; s=arc-20160816; b=ITeMpCA2HJxSKJBx1bQOjuDh/Xac/2qs2BFcoP9RnL2Ja0OTHb6pgB+qjz9XW/Enrc JxFW2l78ZA8h0mvU3s7fNyVrqjn0byY6MiS8RZwy20/eJU6Qsdj1dRhyN0D92StlXXbc Vbt9zZf0j7pU01FQynGhcKJLbNW1G5+9JC8yiInDuJbEs6szlW8qgQxs7o+ezT2zoniO BvYHvgI4NhPD9Y/dQa1GLS4AAHtDlnhMxK5IrGg5vhSvz2ZV5DkTD2mYsI7/pFeqfN61 rXN4JBaag+Gi3PxMW6yVB4K6R3DOZloOoVCC2Pl1Q8iMFY/+PKTKDUFPJHrHVvMGP5P7 2TgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=7i3PRDzZaCagdX870DDlf1ME8AHW4XdU934H//hZInc=; fh=4y8gsuwLDxtKVFejf8mawMPiykDJgczA5fcHhbCZE28=; b=a+Nfzd0n2d02VDm990BeG5Xc3dC13mWrNLgE3e4uA5zPKdCh4RPWygbyniEgpO+XOu 8hdu895JgNMsvR9rCFSpWPVaygH/CE8O1Q+NfITX6wavPliQ3+bKsHRe9W5kZmnoUYyl +o0mJ/U2GeXUdxfCe7YlMoI8ZIDmRMrn31y88N38X0jjtSJUIsBicepDwDn+sABxSiJo 3jF5qxpc4vUjtqE3AgBZtla8IHTepbygMI7rP0u9rHabPNCuZ7kHS4eRgN99iDbG/+Tb 66bPu15VqoJ97CwmHQK1Je5Sn3Hibm+aihR5a9U6LEil+a5RnJXBrQB1oVHEISfqjC+2 vukQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-84412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p5-20020a63f445000000b005d8e379746asi6547943pgk.630.2024.02.27.18.19.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 18:19:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-84412-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 055CA285003 for ; Wed, 28 Feb 2024 02:19:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39E7A1D54C; Wed, 28 Feb 2024 02:19:00 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A93E1CF8C for ; Wed, 28 Feb 2024 02:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709086739; cv=none; b=a1wSIxGhPkIYTSyf0LOq435W3pjiZL2KXswvrnCtjpojTEFs7ZKbqUShOhA5Pic+lvJixXG79+5G4zDbqqQ1YTvcNSlZAeYViku5v1ec7vufmZ8iqser/BwLt/Mp549PfuaTrFU7fe6mx3Kmsm86rTRFNP5Ba2oGQNEwRId4TwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709086739; c=relaxed/simple; bh=R8J8v9gASL1zih1cis7pGYntvqoft304Fk3/CNwsKwo=; h=Message-ID:Date:MIME-Version:CC:Subject:To:References:From: In-Reply-To:Content-Type; b=rz8Nzi8G0u7QcSLWpcVf+tk4yQZ/dnE43LD2cfBwLRWm6Plu1ADZJBION829WT7vwBmrrpfONWVl+SEOP1VymqpMx8CxLHmeLIjzkyEthVlCarlrx+SuFGF0YBTS5R3etaf3mL2rtPsx4qAD3QzY2GxRJ3sVPROHCxYhI0I5VYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Tkygj239XzLqSg; Wed, 28 Feb 2024 10:18:09 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 5DA6A140499; Wed, 28 Feb 2024 10:18:48 +0800 (CST) Received: from [10.174.178.120] (10.174.178.120) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 28 Feb 2024 10:18:47 +0800 Message-ID: Date: Wed, 28 Feb 2024 10:18:47 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , , , , , , , , , , , Subject: Re: [Question] CoW on VM_PFNMAP vma during write fault Content-Language: en-US To: References: <20240227122814.3781907-1-mawupeng1@huawei.com> From: mawupeng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemd200001.china.huawei.com (7.185.36.224) On 2024/2/28 10:10, Matthew Wilcox wrote: > On Wed, Feb 28, 2024 at 09:55:24AM +0800, mawupeng wrote: >> On 2024/2/27 21:15, David Hildenbrand wrote: >>> On 27.02.24 14:00, David Hildenbrand wrote: >>>> On 27.02.24 13:28, Wupeng Ma wrote: >>>>> We find that a warn will be produced during our test, the detail log is >>>>> shown in the end. >>>>> >>>>> The core problem of this warn is that the first pfn of this pfnmap vma is >>>>> cleared during memory-failure. Digging into the source we find that this >>>>> problem can be triggered as following: >>>>> >>>>> // mmap with MAP_PRIVATE and specific fd which hook mmap >>>>> mmap(MAP_PRIVATE, fd) >>>>>     __mmap_region >>>>>       remap_pfn_range >>>>>       // set vma with pfnmap and the prot of pte is read only >>>>>      >>>> >>>> Okay, so we get a MAP_PRIVATE VM_PFNMAP I assume. >>>> >>>> What fd is that exactly? Often, we disallow private mappings in the >>>> mmap() callback (for a good reason). >> >> just a device fd with device-specify mmap which use remap_pfn_range to assign memory. > > But what meaning do you want MAP_PRIVATE of this fd to have? Does it > make sense to permit this, or should you rather just return -EINVAL if > somebody tries to mmap() with MAP_PRIVATE set? I think return -EINVAL if somebody tries to mmap() with MAP_PRIVATE and MAP_MAYWRITE is reasonable to me. Read to this pfnmap vma will not trigger fault. >