From nobody Mon Feb 9 13:01:35 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 A1EFE1CB332 for ; Thu, 26 Dec 2024 17:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735232846; cv=none; b=NKuUcV0LzddmW6j8wqW0OgzFLb+HSuoFALf39BP9hTtjJfiyS6mKfkZvG7SXvKc7pIuzVRMW+En/w/6KtrVoLBnPS6fCFFqgHSrVnr4u4GG7FGybr8kozye1wC4Zr2MyR4yq6KGMfiPJI00WOY1whMSJy7qEn7Ww1hLNpRJ8rDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735232846; c=relaxed/simple; bh=p/o5ZGpP7QNevNaCwrDZS9y9Ty/3GQzxxQCTMzyjkLg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QWn51swU5bpyF3cTi5VGyDow7tFAXDZlBEWMSl0c2RM9G1tCA3eOlX6CeTOORp/hhA/0FDiYRZ0J1xCYdmKxpzuxbpajMmdyb/VIXKiZNe3Khz4vcfxtI6+Pcv2o7MfJKBK4FEF90MHP/re4TZV7XTesJdfJEcIRpV+IEKMSaEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MkiC76Vt; arc=none smtp.client-ip=209.85.214.202 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--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MkiC76Vt" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2166e907b5eso79305785ad.3 for ; Thu, 26 Dec 2024 09:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1735232844; x=1735837644; 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=zZzt97suQHoGz3iLHkiBfewFYx04NIJnrpXSSuwtyuU=; b=MkiC76VtsdXiWuhgh5zm9EJLqQUGnngy09F9f+kbH8INJugR6HEPwy2e4EMqmv7UJM v5cGRCoZ9aMF5j5jSFi45tcN3v8E9xNciP5ntwaK3iYTR/D7Du/+ywDLKUXuvFwWnFIE x2uH+kcg2Ko5MGOsWV2PybJkPeAVX70UEYIUXVGR8wwA/S89ucBZ3r2IwOQIgbTVdACV gtE+BiQ3lSjw9rOm6i4cSxVWzAexaavRuVkDvdIYVBvHACiJa6+uNegJYIGNyabiKWDZ P6gpkrZ2LOSQY8NswY+sGT2K0BLyqLgML9aPBTQlCNoNlx0ilI/e1hF2bo1W16Dlcn3f 9rEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735232844; x=1735837644; 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=zZzt97suQHoGz3iLHkiBfewFYx04NIJnrpXSSuwtyuU=; b=HVzLYCgBDXWy+ezrFnK+KdHMoAskOPndmAZIg+bxboxUL6bt3qT2zJOKam3/bVwZG1 jzbEyPouB/SWvViMNalntoDl63lHhRRxW2A9DDAshx/gcFKTAxlk/zfY64HogPvEt4F8 c2O8H3wTbE5STMuRDvLZpV3zJs2vhrE3jsLFNQ3b9iFnMFFcfEDOaxpi4u34oAxNj/Xt NuNxiiij/hXC4buSVCNozu9GvxNTb9jk5DXhYucXhOhvI6FcAH+U6JjrUUKdVaaQzyIL 2OPh93QAmGETP17TmcKVBO9srP9Nn8qtBhAnI2uzKgVwCrH/p8F0qituOD2FIuSMIsow UIUg== X-Forwarded-Encrypted: i=1; AJvYcCWV0f3UAgKGs5RoEXh2HpBYvP9Y2ZLyhC6Ex537B2WuUngqY09RbS77gFme09RQx8a1CxhLpM7bl0QI2/k=@vger.kernel.org X-Gm-Message-State: AOJu0Yyvx/RSptVlXc96UuoeL9gPAQV4O6OP70t0iuvjE35YaFJ5oypu 1Ot00Yrd3iJMGWSF3UMJF4uHWeNXPyNSR/cq1YvCISBySYWwvKEfU36vSVCetNPXmoHmoj4aE+2 fSg== X-Google-Smtp-Source: AGHT+IEAlsKyIxUvD+OjguaAw8zgyVzbZEnVmDfknkzudP9YDfj4nmndYPZJH96mZmFPgzBT4t688/RysUg= X-Received: from plbkn3.prod.google.com ([2002:a17:903:783:b0:216:5441:d855]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f54e:b0:215:e98c:c5b5 with SMTP id d9443c01a7336-219e6e8c5c5mr356653565ad.1.1735232843904; Thu, 26 Dec 2024 09:07:23 -0800 (PST) Date: Thu, 26 Dec 2024 09:06:57 -0800 In-Reply-To: <20241226170710.1159679-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241226170710.1159679-1-surenb@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241226170710.1159679-6-surenb@google.com> Subject: [PATCH v7 05/17] mm: mark vmas detached upon exit From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: peterz@infradead.org, willy@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mjguzik@gmail.com, oliver.sang@intel.com, mgorman@techsingularity.net, david@redhat.com, peterx@redhat.com, oleg@redhat.com, dave@stgolabs.net, paulmck@kernel.org, brauner@kernel.org, dhowells@redhat.com, hdanton@sina.com, hughd@google.com, lokeshgidra@google.com, minchan@google.com, jannh@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, klarasmodin@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When exit_mmap() removes vmas belonging to an exiting task, it does not mark them as detached since they can't be reached by other tasks and they will be freed shortly. Once we introduce vma reuse, all vmas will have to be in detached state before they are freed to ensure vma when reused is in a consistent state. Add missing vma_mark_detached() before freeing the vma. Signed-off-by: Suren Baghdasaryan Reviewed-by: Vlastimil Babka --- mm/vma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/vma.c b/mm/vma.c index ce113dd8c471..4a3deb6f9662 100644 --- a/mm/vma.c +++ b/mm/vma.c @@ -413,9 +413,10 @@ void remove_vma(struct vm_area_struct *vma, bool unrea= chable) if (vma->vm_file) fput(vma->vm_file); mpol_put(vma_policy(vma)); - if (unreachable) + if (unreachable) { + vma_mark_detached(vma); __vm_area_free(vma); - else + } else vm_area_free(vma); } =20 --=20 2.47.1.613.gc27f4b7a9f-goog