From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.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 145403C196B for ; Tue, 17 Mar 2026 12:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773751834; cv=none; b=QfigOsP3Hu7Vm7P7CObVpewG4gg3cw5XMhcUH4zkoZ8S9lgvPciobUOWRYEdaUuS9O9WpdUVo/asJxhvxlMqyiOSeqjpziOh8Zo06Zk4dNOe+1oEkCK6nt8avD00n6wq5XF7ndUr71kgC0kwQR0n7Ao3z5pOY/9/F1ETASR7IAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773751834; c=relaxed/simple; bh=MutvLyITR0FLBjKX77etYTALhDMlqhgzWMicBWGFLo8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=m6VZUzTxJUqkfjeNu3+W/+1SwU31HwHFt2u6lIRrjEAigqKK1ILT3yp7g9QiF2u1kZgBoSn+kxfl0pryi7YUuBE5yEvlh6NylAmAwrP00X07epBTyUdRqBtSMPbofkV/rNYR1aSgr08k7tBDL3VnKl/J4JJmzXaUkx/+mHNQyZ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--hmazur.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JABHckih; arc=none smtp.client-ip=209.85.221.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--hmazur.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JABHckih" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-439bab2d095so3481265f8f.3 for ; Tue, 17 Mar 2026 05:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773751831; x=1774356631; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ouPtvrktc39JxypPytkX8WaZzIB5CkXK3RuOBnNqCp0=; b=JABHckihFcsXyGherWFlZ8Ct8JF7jkzN8wcF4+JOFDg4WX+vEvUpTerJN/SU2rY0zb THLNAaHXqU6EB8lC8Ner4W/6HwWagxC6Q8VAQ0zL1VJfWAGHUdl35BqRjVsmD6b3Oita JwLeW6Mith4Pyeqzi57dKcGxXhY1NYAFiyWt295uvgv5nUnjxQDlwsGwxkV5jI16d/by SfDSJOJU7h6jiAN8d/pb2PvEwhxp3mnzjQRPBBHY03SB3dzkJbEAbQfT+FZLjhBbqqQ3 7AMsbxHQCcJXtPUHiHjrXoTQ0kjXdmwngY0wgTD7i5i48QChNx3OEGX9nggwKata0LaD 8HpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773751831; x=1774356631; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ouPtvrktc39JxypPytkX8WaZzIB5CkXK3RuOBnNqCp0=; b=rk2Av/pcTnfm7td/G2FMN0j/rn5vhMsxpMIEB3LkqtVnbddX6L99ozoLIPvJefJ4xF 1ZadBJIFIBGo1QzRkCQYTzYZILcwIF4e9VoRlxDorh2F7P60MHj0pc3T1Ksckna2D7RA bBV2cZa6k3sDmukbP9+CypxdVuHfVCU5bs1FKSJn6Tvz6aAQeq120lQG1pZpjz8/F+wY dZ9i/BLmwVGYvGDT7Osi9C4MperWg8ENekgCrfUIE0+uZgnOT6jm3m05F2eizP1Esop7 3FipSccXkS1lXm/nPyGUASHU+D08qJshY1FUTcUnuo3MQjXGKVOKFpXMk99Lbc973p/b aODg== X-Forwarded-Encrypted: i=1; AJvYcCXhwImU8mim5MXYy7yfMNihLeB0vlc5KrNNFhbee+NJoT2O6w5NL4U1FYGI7a4eUpbt30ffFG/YgofBUo8=@vger.kernel.org X-Gm-Message-State: AOJu0YyFv7SE7beUNNTgR5kaiqnijME6he3ytmvzlalgi78PqaLGc0VY Edjklyc0U61fxp+6mB/Is84YMu4vxUihIa+kwWHluB9sKnH89ZLOhw42iP2l0J/A0pqE8kTyATO uTq4gLw== X-Received: from wrbgx30.prod.google.com ([2002:a05:6000:471e:b0:439:f5db:2455]) (user=hmazur job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:612:b0:43b:4077:c187 with SMTP id ffacd0b85a97d-43b4077c7f7mr16938919f8f.38.1773751831147; Tue, 17 Mar 2026 05:50:31 -0700 (PDT) Date: Tue, 17 Mar 2026 12:50:19 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.851.ga537e3e6e9-goog Message-ID: <20260317125020.1293472-1-hmazur@google.com> Subject: [PATCH v2 0/1] Encapsulate the populate and alloc as one atomic From: Hubert Mazur To: Andrew Morton , Mike Rapoport Cc: Greg Kroah-Hartman , Stanislaw Kardach , Michal Krawczyk , Slawomir Rosek , Lukasz Majczak , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hubert Mazur Content-Type: text/plain; charset="UTF-8" Hello, thanks for the review of the v1 patchset. I tried to make v2 diff as small as possible and without a modification of the core logic. When a block of memory is requested from the execmem manager the free_areas tree is traversed to find area of given size. If it is not found then a new fragment, aligned to a PAGE_SIZE, is allocated and added to free_areas. Afterwards, the free_areas tree is being traversed again to fullfil the request. The above operations of allocation and tree traversal are not atomic hence another request may consume this newly allocated memory block dedicated to the original request. As a result - the first request fails to get the memory. Such occurence can be spotted on evices running the 6.18 kernel during the paralell modules loading. Regards Hubert Changes in v2: The __execmem_cache_alloc_locked function (lockless version of __execmem_cache_alloc) is introduced and called after execmem_cache_add_locked from the __execmem_cache_populate_alloc function (renamed from execmem_cache_populate). Both calls are guarded now with a single mutex. Changes in v1: Allocate new memory fragment and assign it directly to the busy_areas inside execmem_cache_populate function. Link to v1: https://lore.kernel.org/all/20260312131438.361746-1-hmazur@google.com/T/#t Hubert Mazur (1): mm/execmem: Make the populate and alloc atomic mm/execmem.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) -- 2.53.0.851.ga537e3e6e9-goog