From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (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 C68CA48CFC for ; Sun, 26 Oct 2025 22:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761517767; cv=none; b=Tt1KHqtdZKh0AguvBOKPo7zbVHUOLNKaBnbOJ2L1m5tlGvrp3vb3KUmKNXGaqOpxKP3EZeh0kyVhHcHEXLeseIVB7x2u3bIjzbSWlVHyld/mEOp4SW11i811stVrcmQUYKIeIcFVAp7G8oxg4+WbgNedsizet/0H4N+rdsmW/eQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761517767; c=relaxed/simple; bh=Y0P2AWqPYjaMFSx/E/QMTTsAvv5s6apFpZPwSBNhObU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=f+kkdSi6tU52mCE0SBfF95boem2kv88c6jTqvf4Tb4ySiI5aGL8+xt49kuILCzeBX9xkTHr35o16P8izo4LaI/us784xDUueGzp5k9zYq1sh/j31dU9RKSD74i5sip7Vj2ubW6+OzxTmVL89Xn+HRPsI07/JODAl1LpjN/HfHyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YvIzxQ/6; arc=none smtp.client-ip=209.85.208.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YvIzxQ/6" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-63c4999fa3dso277441a12.3 for ; Sun, 26 Oct 2025 15:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761517764; x=1762122564; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=66iqL1wQDJrMjUMimUYRUQT7RhtIF8bdulrGmkclbmU=; b=YvIzxQ/6U5c5SMq6JGippU091DZSzSWjnadHhpacIJ7VqbHw9AN0LAR0IvwlvM9tMr oXmXMkgMwJ1EOWA9ONJePTVOKyRKrnr+af09vZ5KUVNiAQwGJQj3NgYMcT1LuX5jhrzU 497ZWhHo/1Hj27TeZPxisYH20CYUUTaXgcbxjzKatNFCAlJXXx+k6yV2mhGwF33awFY6 7eoJo5g3adCaxCopj/0cHbzY+mU2nWN8FnO4Bieel5mV+ihBkNs0uuKRMlih+rap3RMb Kk25as94xVBi8AWrQA2viOJbHwo1xtoqWXOQj9W5ttDpaPHypJqlG49kXQNu7kuph2cJ 1xOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761517764; x=1762122564; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=66iqL1wQDJrMjUMimUYRUQT7RhtIF8bdulrGmkclbmU=; b=LPZX+9fD/yB4BKqid/E6HeYeynX2tbBAJyDTcSjzV5w2MoTrBSbjAwJiZxEN2tJyh3 lD5LuUpQX26ITzsbYUd75qd/YbPYMIxB8ZKGD1dd2yECWDu8b24i3y/0UEYMC6tJnQrY Rb7RZgbCeMNO5W8+W7KtWYvij2jWoj1k5VdzN1VYdpTGCAoPm5qKVh0EmX94//qo7QKu jMg+7caQIbOrrvC1n76PlC5RuqyoJnME3t7n98lRGO6Jw3xwczF0E2WZtEqB+SUvXPpX BVGxfsMXkXFu7gUWoBSrDxS18g0h/gOkN44hBYDOM2xDqvbEzg5le9s+D5VoR1pM3nv5 ppwQ== X-Forwarded-Encrypted: i=1; AJvYcCXLmkAgTu4RTFaJxA3HRld8WtlhcptAG3ZEyXXSBqfejxC/86CERvBNaPjrMjd+SpZwflbfKHvJrrLa41Y=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl24s8isLw1cT9Z9fAlmIJc5TS52F3GJzJ3KG5hapb99Zh9Y4o a5i2T/O+18iZnYhSBc9CeuqF8Y0vVC65DEtnKS8VaJR8GCHKS35zOazK4iObIrlLatl5u1MbOcG bldd71ofuDoBYuQ== X-Google-Smtp-Source: AGHT+IEFiLJX44hMWNXHZC3Aih1gij7lk8DQBXxxJ2bwgJL5TDkN/S5/hEJ472CJdxkQKTEOJdcGAy+su2hzzQ== X-Received: from edf6.prod.google.com ([2002:a05:6402:21c6:b0:639:c8c6:de62]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:26d1:b0:63e:14c2:2818 with SMTP id 4fb4d7f45d1cf-63e14c22f06mr15645925a12.17.1761517763982; Sun, 26 Oct 2025 15:29:23 -0700 (PDT) Date: Sun, 26 Oct 2025 22:29:23 +0000 In-Reply-To: <20251025114801.GWaPy48dhlZ_EVoqKi@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250924-b4-asi-page-alloc-v1-0-2d861768041f@google.com> <20250924-b4-asi-page-alloc-v1-3-2d861768041f@google.com> <20251025114801.GWaPy48dhlZ_EVoqKi@fat_crate.local> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH 03/21] x86/mm: factor out phys_pgd_init() From: Brendan Jackman To: Borislav Petkov , Brendan Jackman Cc: Andy Lutomirski , Lorenzo Stoakes , "Liam R. Howlett" , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , Axel Rasmussen , Yuanchu Xie , Roman Gushchin , , , , , , , , , , , , , , , , Content-Type: text/plain; charset="UTF-8" On Sat Oct 25, 2025 at 11:48 AM UTC, Borislav Petkov wrote: > On Wed, Sep 24, 2025 at 02:59:38PM +0000, Brendan Jackman wrote: >> +static unsigned long __meminit >> +__kernel_physical_mapping_init(unsigned long paddr_start, >> + unsigned long paddr_end, >> + unsigned long page_size_mask, >> + pgprot_t prot, bool init) >> +{ >> + bool pgd_changed; > > I have to say, that pgd_changed is yuck but I don't have a better idea and > this has happened a long time ago anyway. > > How about you have the caller pass in false: > > bool pgd_changed = false; > > and then callee sets it to true when it does so? Sure. Per Dave's feedback I am still slightly hopeful I can find a way to come in and refactor this code so that it's gets cleaner for you guys and then ASI becomes a natural addition. So far I don't come up with anything in init_64.c but I'm still planning to stare at set_memory.c a while longer and see if anything comes to mind. So maybe we'll be able to reduce the yuck factor a bit. >> + unsigned long paddr_last; > > The tip-tree preferred ordering of variable declarations at the > beginning of a function is reverse fir tree order:: > > struct long_struct_name *descriptive_name; > unsigned long foo, bar; > unsigned int tmp; > int ret; > > The above is faster to parse than the reverse ordering:: > > int ret; > unsigned int tmp; > unsigned long foo, bar; > struct long_struct_name *descriptive_name; > > And even more so than random ordering:: > > unsigned long foo, bar; > int ret; > struct long_struct_name *descriptive_name; > unsigned int tmp; Ack >> + >> + paddr_last = phys_pgd_init(init_mm.pgd, paddr_start, paddr_end, page_size_mask, >> + prot, init, &pgd_changed); >> + if (pgd_changed) >> + sync_global_pgds((unsigned long)__va(paddr_start), >> + (unsigned long)__va(paddr_end) - 1); >> + >> + return paddr_last; >> +} >> >> /* >> * Create page table mapping for the physical memory for specific physical >> >> -- >> 2.50.1 >>