From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF40E77173 for ; Fri, 6 Dec 2024 09:25:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EA396B01FA; Fri, 6 Dec 2024 04:25:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9990A6B01FB; Fri, 6 Dec 2024 04:25:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8391E6B01FC; Fri, 6 Dec 2024 04:25:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6607A6B01FA for ; Fri, 6 Dec 2024 04:25:07 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D2B7EAF1CD for ; Fri, 6 Dec 2024 09:25:06 +0000 (UTC) X-FDA: 82863999456.19.7A0B422 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf30.hostedemail.com (Postfix) with ESMTP id D7A6180009 for ; Fri, 6 Dec 2024 09:24:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=QzLceQVi; spf=pass (imf30.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733477086; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RZS6F1TKgzJqFxis0CrZzfpp//nfgLkDyjeydfC6dVc=; b=aL7K7za7BHeCe5VpzoS/4uS0Kuk3F4BpSKjXvLSeOiWFlTXSyH4thL5TlkPSMpDNlFyPCz 9c9bgQ+go94U0K2P/dRC/JaZ8xKzo5nRPoqpCA4AtTtsxfbz2NwVwedcRFkk6ixn1S09BT 6XXdsldgFk5ogmGf36pFBGhMADo5xaQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=QzLceQVi; spf=pass (imf30.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733477086; a=rsa-sha256; cv=none; b=1XQGfFti+AkHrKO+P2EJvKLkFDkqLFp/n13mZTO1rZaG+x0supqL7CBp/Uv92slwNowSyf G/7RvPjLBlqQ3nPZrFkg7yKK31sXXuWRaaUU2Xd/i7gPsWz1hAg/lVsRfXK3lFhI1IiAH5 qAxuzSXc3ZLh43GvKjNS0kTWeSJpFec= Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B5KUr8a011023; Fri, 6 Dec 2024 09:25:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=RZS6F1TKgzJqFxis0CrZzfpp//nfgL kDyjeydfC6dVc=; b=QzLceQVio46n4VJnVjsTBKG7JWiYjMOnX94zbJNo9HHaEn Bg6zUM+0R8TruDBeTNigXuAs+6XimhS/+fwamln9DpY91ygxV3zn3F2/FnkBU4zp GhvtFgTTbYd8aWspcXdXrw6kdeOuuHIk6jEmqi7rAlU0L9+c/RXh7bfhDqwG3F54 UoMdAYw8c9+y2SboQkbW9jKTdcN5PnY72g9sxDz04U1KwqGUSGAyCBLUN5y+N2zg 9LHEf2e1VoN8JhbyWCsQxPmsF5GrrYASa+WunSCy0Af9QQ+XxDlqMA0e33aUXl52 g6naz0zidXpLJqZzhYpJoYAfVw5FUoh0EAkPkqBg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43bk99jmtb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Dec 2024 09:25:00 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B65J76C008622; Fri, 6 Dec 2024 09:24:59 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 438f8jwwkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Dec 2024 09:24:59 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B69Ot1v10486200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Dec 2024 09:24:55 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA7E020043; Fri, 6 Dec 2024 09:24:55 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F032320040; Fri, 6 Dec 2024 09:24:54 +0000 (GMT) Received: from osiris (unknown [9.171.17.195]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 6 Dec 2024 09:24:54 +0000 (GMT) Date: Fri, 6 Dec 2024 10:24:53 +0100 From: Heiko Carstens To: Guillaume Morin Cc: Nathan Chancellor , Vasily Gorbik , Alexander Gordeev , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song , Andrew Morton , Peter Xu , David Hildenbrand , Eric Hagberg , linux-s390@vger.kernel.org Subject: Re: [PATCH v3] mm/hugetlb: support FOLL_FORCE|FOLL_WRITE Message-ID: <20241206092453.9026-A-hca@linux.ibm.com> References: <20241206045019.GA2215843@thelio-3990X> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7EedieBvwZ570EpYYf5NVEvE0HRd2YQh X-Proofpoint-ORIG-GUID: 7EedieBvwZ570EpYYf5NVEvE0HRd2YQh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1011 malwarescore=0 priorityscore=1501 spamscore=0 mlxlogscore=539 impostorscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412060065 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D7A6180009 X-Rspam-User: X-Stat-Signature: jec5yh3shr1yykgrwzryf6cpupnq839i X-HE-Tag: 1733477071-955290 X-HE-Meta: U2FsdGVkX18sfUhiHxYq4vc9UBzM+y3EQ39f1AvI9RPVun3pFuZsg5ZcVp6l4nz1E32FtvMLnheavcXm2dLHKNaaYVYYUX7CTschG8Qm9uQwAeOWKfGqzsc32dL2R1rldyojTLp6aj65jsi/kOG1oA3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WlJgiGER9lCUIpRN7NmbPgWuk+IIA12LJk//KNPMJXCDthLtu2YXREWVjUs7YTzNtJIV4hfrpoNj2A/+vPsTFhcS6b/4JrYDt/coZX1fRD7KE/iWFBBszVOLc113cq+VMPsSjTdMNzC/iAmk94KpSR5Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Dec 06, 2024 at 06:27:09AM +0100, Guillaume Morin wrote: > On 05 Dec 21:50, Nathan Chancellor wrote: > > > #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES > > > +/* FOLL_FORCE can write to even unwritable PUDs in COW mappings. */ > > > +static inline bool can_follow_write_pud(pud_t pud, struct page *page, > > > + struct vm_area_struct *vma, > > > + unsigned int flags) > > > +{ > > > + /* If the pud is writable, we can write to the page. */ > > > + if (pud_write(pud)) > > > + return true; > > > + > > > + if (!can_follow_write_common(page, vma, flags)) > > > + return false; > > > + > > > + /* ... and a write-fault isn't required for other reasons. */ > > > + return !vma_soft_dirty_enabled(vma) || pud_soft_dirty(pud); > > > > This looks to be one of the first uses of pud_soft_dirty() in a generic > > part of the tree from what I can tell, which shows that s390 is lacking > > it despite setting CONFIG_HAVE_ARCH_SOFT_DIRTY: > > > > $ make -skj"$(nproc)" ARCH=s390 CROSS_COMPILE=s390-linux- mrproper defconfig mm/gup.o > > mm/gup.c: In function 'can_follow_write_pud': > > mm/gup.c:665:48: error: implicit declaration of function 'pud_soft_dirty'; did you mean 'pmd_soft_dirty'? [-Wimplicit-function-declaration] > > 665 | return !vma_soft_dirty_enabled(vma) || pud_soft_dirty(pud); > > | ^~~~~~~~~~~~~~ > > | pmd_soft_dirty > > > > Is this expected? > > Yikes! It does look like an oversight in the s390 code since as you said > it has CONFIG_HAVE_ARCH_SOFT_DIRTY and pud_mkdirty seems to be setting > _REGION3_ENTRY_SOFT_DIRTY. But I'll let the s390 folks opine. > > I don't mind dropping the pud part of the change (even if that's a bit > of a shame) if it's causing too many issues. It would be quite easy to add pud_soft_dirty() etc. helper functions for s390, but I think that would be the wrong answer to this problem. s390 implements pud_mkdirty(), but it is only used in the context of HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD, which s390 doesn't support. So this function should probably be removed from s390's pgtable.h. Similar the pud_soft_dirty() and friends helper functions should only be implemented if common code support for soft dirty would exist, which is currently not the case. Otherwise similar fallbacks like for pmd_soft_dirty() (-> include/linux/pgtable.h) would also need to be implemented. So IMHO the right fix (at this time) seems to be to remove the above pud part of your patch, and in addition we should probably also drop the partially implemented pud level soft dirty bits in s390 code, since that is dead code and might cause even more confusion in future. Does that make sense?