Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2522942rwb; Mon, 15 Aug 2022 06:57:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Izp4SIVrMnX3Orwq9v0kLJcDFFH3zuQiI0nP24sMQjqglsCFgBYJbqWyElzmvM6WEoTMV X-Received: by 2002:a17:90b:1110:b0:1f4:fc9a:be2d with SMTP id gi16-20020a17090b111000b001f4fc9abe2dmr27869483pjb.41.1660571845659; Mon, 15 Aug 2022 06:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660571845; cv=none; d=google.com; s=arc-20160816; b=pYD2JfKVZHi7QrBpHHOWGKZdtovZhtQC8Nh5WPBMqg+oJbzo01GGRj5JMBnKNmy8r9 pu/OnGmYWW4XyJGJAtoC26RcBsBCuSTGK4HkwOqueHn0Mh8ZQBmDkZTyiEkFlI6fOqB1 zDX7vJqAoaETiSMmJm6MXosRa+wpGZJZYvyvnjsGRbbP3iZSREdKEAjg7O3tIkiQgE+U zvcD8mjBJ6sbNP2VBXGhAxhUdwgY6BqQg65rn9qbKEfkz/nIo0Sfo++ElvUMoj/NjFs1 /U4IblJGt2r7i5zlx3bi2Td1u+cH2Tges1vKzuh8yh0Q0YtmnpVG+gXSgMbZgIY22Dxy W8Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=eaRViY6pucTtow3bgZIPD2Vkh83IVZr4lnZB/1dV7zs=; b=SxvfEARXxaZcbwpot8QgcMWe7RuaJ9/b+c5PLbDbQKhlLnByWsA3EkwYn6/yq2U1tG k8fuKLlIZAtlyViRzjHYWOY7y8fjdBLcpjlLaE1iR/nbmXyTSQp5zY56RoYnc72GW9rI eyJLh1aJH4BBbc7wSwsw1WGe5bNzrBC+Dxz4LlB7rlhIyNqdf0WAAs1AfhCMGh99nwGg OfL3v3qzjFY54tVFQjkbEBgpcyDI4+YeEXERR35fZPVVql/EEc9szJJ7pJYD+KEUNU5O VYSVQ1Yaj/CXRT/jCSfvUT+cjctpwGITKN6QczUVJ/5gtgJXGKj1YgUDoY3Va5upQlpL ZQzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AVhYp0Yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020a170902e84f00b0017259702a10si8238073plg.422.2022.08.15.06.57.12; Mon, 15 Aug 2022 06:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AVhYp0Yl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242167AbiHONgE (ORCPT + 99 others); Mon, 15 Aug 2022 09:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbiHONgB (ORCPT ); Mon, 15 Aug 2022 09:36:01 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4326013E16; Mon, 15 Aug 2022 06:36:01 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27FDIcOu032536; Mon, 15 Aug 2022 13:35:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=eaRViY6pucTtow3bgZIPD2Vkh83IVZr4lnZB/1dV7zs=; b=AVhYp0YlYP85MwZ2J9bSZT/ru6Q5BDOe8dLNGrNf2zMar9UMvHBPJmP0xHTKgiEa19HW iAg5M3QlKG48q61FCbGo/BqfoougQYbCwLM1M0mgYI/kV9xR3L81TGdpYc427zhiMP/M ZiqES4DRbxYoTxtt7LknqsoFcuuvuTay7R7LyrGLoR+sf5ZoKxxnwPSbfWCRfWEZfY61 6/h85R72ka6iHpmyBIa4EUHJTnnWlFUtIj0S8sIZM8u7Gb8dGr7LtoCuEETIjW7/Gjtq FWc4wZCeV1PVww/LpmUu484y9kU3m9GOBHobvfu2hy7IxuZx9Tij9UEiQfAt+J7DPJE6 7Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hypwtrbyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Aug 2022 13:35:57 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27FDIs9s000774; Mon, 15 Aug 2022 13:35:56 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hypwtrbxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Aug 2022 13:35:56 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27FDKxIv030037; Mon, 15 Aug 2022 13:35:54 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3hx3k9a1x3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Aug 2022 13:35:53 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27FDZpnw31588852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Aug 2022 13:35:51 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9F33811C052; Mon, 15 Aug 2022 13:35:51 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45B6511C04C; Mon, 15 Aug 2022 13:35:51 +0000 (GMT) Received: from thinkpad (unknown [9.171.38.199]) by d06av25.portsmouth.uk.ibm.com (Postfix) with SMTP; Mon, 15 Aug 2022 13:35:51 +0000 (GMT) Date: Mon, 15 Aug 2022 15:35:49 +0200 From: Gerald Schaefer To: David Hildenbrand Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH v2 2/2] mm/hugetlb: support write-faults in shared mappings Message-ID: <20220815153549.0288a9c6@thinkpad> In-Reply-To: References: <20220811103435.188481-1-david@redhat.com> <20220811103435.188481-3-david@redhat.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: MJ3X9Xzr4PUIE9CAayI4halGlGSPtmrU X-Proofpoint-ORIG-GUID: 4HAYzzsF6Hbu_TodGuw7lQnxBf51R8Hp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-15_08,2022-08-15_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 bulkscore=0 clxscore=1011 priorityscore=1501 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208150053 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Aug 2022 11:59:09 -0700 Mike Kravetz wrote: > On 08/11/22 12:34, David Hildenbrand wrote: > > If we ever get a write-fault on a write-protected page in a shared mapping, > > we'd be in trouble (again). Instead, we can simply map the page writable. > > > > > > > Reason is that uffd-wp doesn't clear the uffd-wp PTE bit when > > unregistering and consequently keeps the PTE writeprotected. Reason for > > this is to avoid the additional overhead when unregistering. Note > > that this is the case also for !hugetlb and that we will end up with > > writable PTEs that still have the uffd-wp PTE bit set once we return > > from hugetlb_wp(). I'm not touching the uffd-wp PTE bit for now, because it > > seems to be a generic thing -- wp_page_reuse() also doesn't clear it. > > > > VM_MAYSHARE handling in hugetlb_fault() for FAULT_FLAG_WRITE > > indicates that MAP_SHARED handling was at least envisioned, but could never > > have worked as expected. > > > > While at it, make sure that we never end up in hugetlb_wp() on write > > faults without VM_WRITE, because we don't support maybe_mkwrite() > > semantics as commonly used in the !hugetlb case -- for example, in > > wp_page_reuse(). > > Nit, > to me 'make sure that we never end up in hugetlb_wp()' implies that > we would check for condition in callers as opposed to first thing in > hugetlb_wp(). However, I am OK with description as it. Is that new WARN_ON_ONCE() in hugetlb_wp() meant to indicate a real bug? It is triggered by libhugetlbfs testcase "HUGETLB_ELFMAP=R linkhuge_rw" (at least on s390), and crashes our CI, because it runs with panic_on_warn enabled. Not sure if this means that we have bug elsewhere, allowing us to get to the WARN in hugetlb_wp().