From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 4C99D3A875E for ; Wed, 3 Jun 2026 15:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780499355; cv=none; b=JK8BH9N2eHj5I4Xmw3VvmJiyvJq2FIEh6k2U+AvkBqQp43IJnSJxBh19GOdw+AjUu79QMuC4WCVDncJb05xGoEe+ne49ADUZKMJu1iIINP5w0NgRyTXEEyBZWxtnqEKmPvHKwonkZQs0rPWqzZ1cKqDCTPV+sNUJPeCFUhFKXS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780499355; c=relaxed/simple; bh=3lPIWtVtkvzi+fsJ1Zi5PKEvgfgJnDc7lTSZu9RQ0V0=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=og4Z7e1639jN7zmVDkWSxxZvDyOK9fk4WvBCQdMDyYMbM4x6Og4BbgJaU4EJKJIPtk7I9kDWxKH0/5AGhv/dfvnmff1U/kXyTgWmpqqGKeQX7jOsIHfnzEKsvZiUlcVEsyNbkKay4haSoPFhKAac045GGMopu4Zp7gHaljZO2E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oYrwtYck; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oYrwtYck" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-36baec934b6so491957a91.0 for ; Wed, 03 Jun 2026 08:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780499353; x=1781104153; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=bndY4Rtt+kF0HA5uw8ulEDrFOIX6yTjDL3dqjriePQQ=; b=oYrwtYck06DJbJEfC8tN0WwOau/tvM4b1AoGIN8hjUuWV+lQoJ/URvcoXs1xOKg0lX 57NeUwjsJG4BJ4XHzGyf+OAMQvXXq5ly9QGw0erdsbIU1e20VKVVA5qVaCAB/TJoKSsF o1SFUB/LnQARyrhMKElRnwffAn/nxrU/nBJQZeYP8bVMXD+HkoICqozbxopvXK/k1qkj xY6xwD2MG77vNVRrneteck4uczqHCwn7rdB84Dice+js4D8GX55CZ/ScAXS/zt4pYS6D I/PdZg7FkMqJ+QHaS6keHmDVLCgTqAmkQsVKP/33XGTjDp9FFEK7RqmS/981QkXubARr f8rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780499353; x=1781104153; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bndY4Rtt+kF0HA5uw8ulEDrFOIX6yTjDL3dqjriePQQ=; b=CQh8MY2iv+++w9c4bkH636wqX+i27t44xNbQaay97n4vCNVPzA6pNPd9oqpud60loF 5rNKBl5hSN4kwL9iW/L08aKaOW/COcQNkJalN1+e78pk+gw9xQ8kTfIitvPAUhUdSKJx hT03mWl9t99zpSRmgrwTKanFk8uNgJL1RKnV9f8taVgSL1O8gnTjVbRciAa1jZX7Fr8J vBrmCqzRb0SjHyTylAHtrLQkgDVzXfRJwtah8Bmg5Ay393rPCW1riyWwTK6D0Wr6t6dQ Vh9swIO/VCDo108BPiIG1GGIBstg3QPBdzWQr1kKL5QK5HWLM1cYUZZQtMP2ltSI1Y4m HMQw== X-Forwarded-Encrypted: i=1; AFNElJ/7cuPy1V23y7+tNawyF4ynQFeEEuemC4d57oHWH30rH79/hz+0opFdbpbxmhpysAO4C4oGBez2bE5Vpe4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3S/EoOgP9LTRMKaSvtmwZLIQaYgVph7XVdcQ0hWJe9tWmjsYL hl43r31yR3yCxRW7yxkXhMdrTrO2fxK3xDThWouW5k5vgE931L+u3P7+ X-Gm-Gg: Acq92OFCHTmHUtSF18ObKKqg2+CM3XugJPUbQHmOo9cuVzsCiM3yEIYLy5RhIPqpsn+ +tsjLFosDDxKc7oy/FZaY641K2UiEsSUK0IjWKyvybOP50NF5/N/CYMMKyEA7FIhnRybeNlzPGs EJP5QUL038xzlHeOKIlIJVwpeYFFPvGES+pkePnkQ4e2bAssp/NAMO/qQlZ8T6Cmz/n+uidO5Ug HtTGelQD4y+uLFuNWlkwbqwO8lDYp6PHOZxqKs1ghnPwnhP43eKJ15xQOfwY9oXifcnButzDEMJ /JfZ9AqPqxs2Pg1wHSLsMXYbzYn+p2luc/+K/6FRpfkVK8afz1WLsrPLPdlGCOxQFnK6xvU8/Yy RYrO+Dvm4kz/bNWAPGcKrMGCfAVdhnlPzkeH4I72k8Fkgo7Tnn4s9RBSGUlLO/aUtkPsStiw1SF pL8zyEkTUXYXkASXOfAQB4XbFtQ54/+zcT X-Received: by 2002:a17:903:22cc:b0:2c0:af09:f3d4 with SMTP id d9443c01a7336-2c164d5f70emr29441875ad.27.1780499353373; Wed, 03 Jun 2026 08:09:13 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f6d2bbsm29577905ad.1.2026.06.03.08.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 08:09:12 -0700 (PDT) From: Ritesh Harjani (IBM) To: Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman Cc: Muchun Song , Mike Rapoport , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nicholas Piggin , "Christophe Leroy (CS GROUP)" , "Aneesh Kumar K.V" , linuxppc-dev@lists.ozlabs.org, Mike Kravetz , Muchun Song Subject: Re: [PATCH v3 03/19] powerpc/mm: Fix wrong addr_pfn tracking in compound vmemmap population In-Reply-To: <20260602101039.1867613-4-songmuchun@bytedance.com> Date: Wed, 03 Jun 2026 20:06:35 +0530 Message-ID: References: <20260602101039.1867613-1-songmuchun@bytedance.com> <20260602101039.1867613-4-songmuchun@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Muchun Song writes: > vmemmap_populate_compound_pages() uses addr_pfn to determine the PFN > offset within a compound page and to decide whether the current > vmemmap slot should be populated as a head page mapping or should reuse > a tail page mapping. > > However, addr_pfn is advanced manually in parallel with addr. The loop > itself progresses in vmemmap address space, so each PAGE_SIZE step in > addr covers PAGE_SIZE / sizeof(struct page) struct page slots. Since > addr_pfn is compared against nr_pages in data-PFN units, it should > advance by the same number of PFNs. The existing manual increments do > not match that and therefore do not reliably track the PFN > corresponding to the current addr. > > As a result, pfn_offset can be computed from the wrong PFN and the code > can make the head/tail decision for the wrong compound-page position. > > Fix this by deriving addr_pfn directly from the current vmemmap address > instead of carrying it as loop state. > > Fixes: f2b79c0d7968 ("powerpc/book3s64/radix: add support for vmemmap optimization for radix") > Signed-off-by: Muchun Song > Acked-by: Oscar Salvador Thanks for fixing it. I guess this was not caught because section size on powerpc is 16MB and with 64K pagesize we have 256 pfns to map. The vmemmap size required for this is 256*sizeof(struct page) = 16KB which is < 64K (pagesize). So basically we never loop in vmemmap_populate_compound_page(), because next = addr+PAGE_SIZE will be > end after the 1st iteration itself. But I agree this is a bug which needs fixing and it can be easily caught with 4K pagesize, where we have 4096 pfns to map within a 16MB section. The change looks good to me. Can we please add stable tag too? Cc: stable@kernel.org Also, feel free to add: Reviewed-by: Ritesh Harjani (IBM)