From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 679B7211A09 for ; Tue, 7 Apr 2026 08:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775549204; cv=none; b=f6/x97qZWPwcYXafA2DEua8LmPzKU4JoiVhqk4k8oHhTShtZCPU3XzkDLnofdWbJo+s806J77ffpvcx9ugcGLRGFeEPuTGDhdub1ph9vHiHerTIW0k86SHlp20sLvDP+9ZBmtq45BFQMxisrUEBd58ftu2beap0mfEL9GrdjF4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775549204; c=relaxed/simple; bh=NmRceV1L1Jc58Vj5SdPFlICOrNkfDx3wn1W5n849k+k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C4RXDZBBNROjA5EqgFmNzgB9OO9IbvllLT8G+QSYshGTvs+XXaYCgnDoUSq7vfBnOHNjVq7I8dLoZdkqBSkAcd9Yop51U9sud8REs0BHlAjqzOXUM9Ff9YFrmnAuHnE+V8eURUre0pcyJLDXqqu0kEISILZtM1Uwfjw2QtMn4+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kksEzBVd; arc=none smtp.client-ip=209.85.128.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--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kksEzBVd" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-488c0fcc6deso1092305e9.2 for ; Tue, 07 Apr 2026 01:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775549202; x=1776154002; 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=ZiARTJkG6bieAVjpVY1nM0z1Q63xfD5pEAGan5ewDbQ=; b=kksEzBVdg+/H/KeHKOLC8bUlkYy391LjyA4MsUF9m0HhTkeuX9mDcq3tzQ5O/jmZGi aeRk7aUqeMO03Qy/gVGlbjgRQza4ekZZ8xGKBlKZ4Hif3vK+CXsp2pFPI/qI9xLqKtml VX52CYVuIPBjihzrgcyCiLOmkHn7zuPnnh+Kvc/0Ciq14GypKz0AiT+OZnCiwnuAzsgY kcE8jsZvYiJdcphQzYI8L7P3GSN+ypjPyw9EWJxuPyegB3tQQwxZ0Mt98AzhA8FlRXdU oua+2Pjrrki4eRl99tZ2K4vNn8PUylm9LgARgNq3XSKL9olMPCdOYaIfMRJQG6X5vTgz ZSUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775549202; x=1776154002; 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=ZiARTJkG6bieAVjpVY1nM0z1Q63xfD5pEAGan5ewDbQ=; b=eSz1tCLPYGflm9n6oYX5f8vkzs0XVhURKT+GbfRmTgi5IgzfGP51WdPeEXrMjZ7OIC yfCDf+m9XK//IdZ8sWTcDzlpgsnOr7Tt98Oii33wM+Ya4JxtzQTuEP2IxpbEB8GEG6PJ B7NY2XgdA0o00SxYODMXih7wK/TfIkJVtAgjC6OnirnAtf0+rSTaW2SffyRG54F3IOAV dAEdf81WRX0dbBAf0YiqsCYH63v53HgJgJYTSsejeSnCkxEfGBvNaLz7Y6nHtWSDQP8M yL2Jpns5IUUVQUmWLY9kNMius7ujCgJc3hWx1S8KV31/mutUTPallWwmvi9uAJ5qwcxK 63tA== X-Forwarded-Encrypted: i=1; AJvYcCVi9wRfvtDH+FvKJ/hiDNXex0maE8WKDH0AZ5IXEv1ovuPg+QpFF46z8aPGj64P3gECZt3r6W8NolioyX8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0pmlR56osOCZCV8tQm7YOXFD9Q972vgOdFIzqO3kfsidsj4ha fqQU3KbiWjIU9NaKiRYiu7UaNuD+UJaUJoCooXxbpdQbhaZF10hXGoF7OvaNWcvVTfH0S6CIJoE OD/guhJHirUNrP1MFhA== X-Received: from wmp9.prod.google.com ([2002:a05:600c:2409:b0:487:37f2:47bf]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a10d:b0:488:be58:bb77 with SMTP id 5b1f17b1804b1-488be58c975mr15356465e9.30.1775549201757; Tue, 07 Apr 2026 01:06:41 -0700 (PDT) Date: Tue, 7 Apr 2026 08:06:40 +0000 In-Reply-To: <31bb8a8e-2ca0-486b-888a-328e9b748ac4@zohomail.in> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260401-vmalloc-shrink-v9-0-bf58dfb997d8@zohomail.in> <20260401-vmalloc-shrink-v9-3-bf58dfb997d8@zohomail.in> <7bc4bba9-24ed-4a69-b9bd-d45d647f48b7@zohomail.in> <31bb8a8e-2ca0-486b-888a-328e9b748ac4@zohomail.in> Message-ID: Subject: Re: [PATCH v9 3/4] mm/vmalloc: free unused pages on vrealloc() shrink From: Alice Ryhl To: Shivam Kalra Cc: Andrew Morton , Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Danilo Krummrich Content-Type: text/plain; charset="utf-8" On Thu, Apr 02, 2026 at 08:23:42AM +0530, Shivam Kalra wrote: > On 02/04/26 07:31, Shivam Kalra wrote: > > On 02/04/26 02:49, Alice Ryhl wrote: > > Should we set nr_pages first? Right now, another thread may observe the > > range being unmapped but still see the old nr_pages value. > > Or is this what you mean? > > struct vmap_node *vn = addr_to_node(addr); > /* Notify kmemleak of the reduced allocation size before unmapping. */ > kmemleak_free_part(...); > > spin_lock(&vn->busy.lock); > vm->nr_pages = new_nr_pages; > spin_unlock(&vn->busy.lock); > > vunmap_range(...); > vm_area_free_pages(vm, new_nr_pages, old_nr_pages); > > > If this is the case, then I agree this will be much cleaner. Yes, I mean that you should change nr_pages first, before you calling vunmap_range(). Alice