Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp222558lqq; Thu, 13 Jun 2024 00:39:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5gGPX7z9AEG8zkjmCbtS4y1SxAVB273USNm2mFfnXnNiXeBjz2bLI0e+tDJPgeBjypbef0fa1tiCQVM1023OvregitBLhEeXPN/+CmQ== X-Google-Smtp-Source: AGHT+IHVapCYdi3MP8oW432djiYBtBvjIBa9Sht7oe3iWzksgWpvaw89NyPCYWelMgE2nxnrc8UV X-Received: by 2002:ac8:5981:0:b0:441:4a7d:4b9 with SMTP id d75a77b69052e-4415abd77e5mr56115641cf.15.1718264382545; Thu, 13 Jun 2024 00:39:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718264382; cv=pass; d=google.com; s=arc-20160816; b=QoI7b6+wpQWSDq7bq1I9asjwL67HybAaO0cSefQWVZuI1bM7XTr8q117soQjR1Ivrt mB+XLTrvf1J3BFjbrdSZV1jy/wS7GpEFLEMdpgyJVyUmPrVyOFcIFy2Pex1VxF1YIixn C17ZsPQ4SYRIFS+UnnGe0EE4RsqV3N2yS94X1M56nkFjn8A2+qDveDfXGsbn4FLcmsZO rdYVFjLShEGuccJmttvcRoWrW7EHsXFKZJC7Tcbhgq9nxW3vZYiUjnz0FVNUI75c7Vmd MTAAMI9Y9J2sPy17WGrpzHNtMEe469qR3Lg+zrGLDosGVTm/jsOnwZcdgUE/hJECRDEQ Nq8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=PJr/sVqqibP7odVJAVm3G5KXSTQ5G/aztZXaBj/Ps0Q=; fh=7FqQY95/6dNosXCjFkEopk0YDb4YCNocz5tbx4U0IiY=; b=SPYlSQiFyuQo1owlCZsdmUtKDKclJpX7T8p/3XDFqtw5JmTB7MZ8vHPUhScHof+v6X zrOnJlwZclW+DzipIqqE0F9GmKjthTEjfh8UO/jIcVpAwEa8ALyOaKHy+3AH41iw3LBW n/0imGtllVHID2Erzj4GDQC3z9XFcpIcUfRES0H9LI0Guj9DXy6tTABcTStZ7oDJ2aw4 UyA+ZTk69YzykzjYU0mK9M1iBDDsk1x/Wj9w3TqYhBJxIcnk+rLfKNBIwtWG13izNndB CFfjz7RXqhfVkuKDzCzQBOukPz9nYiSUzC+4KU9O/Nc2Ph16R3jnXzuLBoFB4HrtHg+p 2f6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Hk6IrMmN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Hk6IrMmN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-212726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44212000565si1551741cf.128.2024.06.13.00.39.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 00:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Hk6IrMmN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Hk6IrMmN; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-212726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 322191C22CA7 for ; Thu, 13 Jun 2024 07:39:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7B8313C908; Thu, 13 Jun 2024 07:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Hk6IrMmN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dKuE2pVb"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Hk6IrMmN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dKuE2pVb" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56D8613C3D6 for ; Thu, 13 Jun 2024 07:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718264360; cv=none; b=am87wcHYifPdQBR13nF3c0QmmY4IC8qKPLscOR1/+jrPw2xqoxz+Gl2T7+tGoWCqephj0juqSWQ2rLGvs0EpNitDAWOOovFhi4s/2KnmcsU/I1gz9RTeDaNGvv4UXe3FwdsKQblIjLVFTNc404iuP90BLukxpK2WHuHm1d/UN1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718264360; c=relaxed/simple; bh=eeRUEo41icEwmxMt46WyBX5D6jIPGfbgEfVlpJjOh/s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kth0R95x8zdvFRo5yRHNDZAaRMZdUxlJwr04/JBBzqeTwbKtaS75TflGJMbvyXFmTbdjm2KorRqUOGKFFSAbVWozm0aEIPT7xm3H0hpFI0Yi0d/omCon/zYDDGQGK2NOeqmk29HZzb6tSRyLtjsZE2BsubsDQihAE0s3kiQzczw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Hk6IrMmN; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dKuE2pVb; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Hk6IrMmN; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dKuE2pVb; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 597463504D; Thu, 13 Jun 2024 07:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718264357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PJr/sVqqibP7odVJAVm3G5KXSTQ5G/aztZXaBj/Ps0Q=; b=Hk6IrMmNmmk6+OnKpC5t1Fwcg7VYXLsRjctko2pjEjG1EzMMSOoNexWIbKwg0b0ubAm3U0 9WntOMQY0sGnUitsr5bPygUGELIHnkDV8sfwZOLwW5F65fgvvAAvXVxyQvOFpSndpRI91P xFx5oThb/plGx5nZfuL2Qsh2ftPuzJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718264357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PJr/sVqqibP7odVJAVm3G5KXSTQ5G/aztZXaBj/Ps0Q=; b=dKuE2pVb2zgiX6DotLeuAj+BGf1xKCV69k885AFnTmtuD7zIla+rVE9LmjHStNJiy8nkZ9 0Z2ts9tc2MNb5FAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Hk6IrMmN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=dKuE2pVb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718264357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PJr/sVqqibP7odVJAVm3G5KXSTQ5G/aztZXaBj/Ps0Q=; b=Hk6IrMmNmmk6+OnKpC5t1Fwcg7VYXLsRjctko2pjEjG1EzMMSOoNexWIbKwg0b0ubAm3U0 9WntOMQY0sGnUitsr5bPygUGELIHnkDV8sfwZOLwW5F65fgvvAAvXVxyQvOFpSndpRI91P xFx5oThb/plGx5nZfuL2Qsh2ftPuzJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718264357; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PJr/sVqqibP7odVJAVm3G5KXSTQ5G/aztZXaBj/Ps0Q=; b=dKuE2pVb2zgiX6DotLeuAj+BGf1xKCV69k885AFnTmtuD7zIla+rVE9LmjHStNJiy8nkZ9 0Z2ts9tc2MNb5FAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D4EBD13A87; Thu, 13 Jun 2024 07:39:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id V9lyMSSiamZ9TQAAD6G6ig (envelope-from ); Thu, 13 Jun 2024 07:39:16 +0000 Date: Thu, 13 Jun 2024 09:39:15 +0200 From: Oscar Salvador To: Christophe Leroy Cc: Andrew Morton , Jason Gunthorpe , Peter Xu , Michael Ellerman , Nicholas Piggin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v5 16/18] powerpc/64s: Use contiguous PMD/PUD instead of HUGEPD Message-ID: References: <92a741b0358fc100ad331760181f66e82781052b.1717955559.git.christophe.leroy@csgroup.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92a741b0358fc100ad331760181f66e82781052b.1717955559.git.christophe.leroy@csgroup.eu> X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FREEMAIL_CC(0.00)[linux-foundation.org,nvidia.com,redhat.com,ellerman.id.au,gmail.com,vger.kernel.org,kvack.org,lists.ozlabs.org]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[9]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 597463504D X-Spam-Flag: NO X-Spam-Score: -4.51 X-Spam-Level: On Mon, Jun 10, 2024 at 07:55:01AM +0200, Christophe Leroy wrote: > On book3s/64, the only user of hugepd is hash in 4k mode. > > All other setups (hash-64, radix-4, radix-64) use leaf PMD/PUD. > > Rework hash-4k to use contiguous PMD and PUD instead. > > In that setup there are only two huge page sizes: 16M and 16G. > > 16M sits at PMD level and 16G at PUD level. > > pte_update doesn't know page size, lets use the same trick as > hpte_need_flush() to get page size from segment properties. That's > not the most efficient way but let's do that until callers of > pte_update() provide page size instead of just a huge flag. > > Signed-off-by: Christophe Leroy > --- ... > +static inline unsigned long hash__pte_update(struct mm_struct *mm, > + unsigned long addr, > + pte_t *ptep, unsigned long clr, > + unsigned long set, > + int huge) > +{ > + unsigned long old; > + > + old = hash__pte_update_one(ptep, clr, set); > + > + if (IS_ENABLED(CONFIG_PPC_4K_PAGES) && huge) { > + unsigned int psize = get_slice_psize(mm, addr); > + int nb, i; > + > + if (psize == MMU_PAGE_16M) > + nb = SZ_16M / PMD_SIZE; > + else if (psize == MMU_PAGE_16G) > + nb = SZ_16G / PUD_SIZE; > + else > + nb = 1; Although that might be a safe default, it might carry consequences down the road? It might not, but if we reach that, something went wrong, so I would put a WARN_ON_ONCE at least. > --- a/arch/powerpc/mm/book3s64/hugetlbpage.c > +++ b/arch/powerpc/mm/book3s64/hugetlbpage.c > @@ -53,6 +53,16 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, > /* If PTE permissions don't match, take page fault */ > if (unlikely(!check_pte_access(access, old_pte))) > return 1; > + /* > + * If hash-4k, hugepages use seeral contiguous PxD entries > + * so bail out and let mm make the page young or dirty > + */ > + if (IS_ENABLED(CONFIG_PPC_4K_PAGES)) { > + if (!(old_pte & _PAGE_ACCESSED)) > + return 1; > + if ((access & _PAGE_WRITE) && !(old_pte & _PAGE_DIRTY)) > + return 1; > + } You mentioned that we need to bail out otherwise only the first PxD would be updated. In the comment you say that mm will take care of making the page young or dirty. Does this mean that the PxDs underneath will not have its bits updated? -- Oscar Salvador SUSE Labs