From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D89E73513 for ; Wed, 28 Feb 2024 12:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709123199; cv=none; b=SB4OCbH629jN+P2eNu6UyVvf0bXuIbjgVxWzUN1xrPnstSiSakFASvpR2CE9gQEEGYSHBAiXShHSkKr6wA/+PGmkO10U/zbKn2J7fuyfc9We1/aTitNJI47+YPjmmmZzrIQ0Xx0i4yA8zJnJhw07Brl8ZbsVf6XF8+TI8cMKjBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709123199; c=relaxed/simple; bh=VRPX8vusgT7bjSb0Awa16g019a+zyCgxgMgMpjkpYEo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G9ouHRi6i/OzNw0HLdp+ZO6R7b3N+Q2yw+pqj0lNKmCe4EvkyzeSWAPW5bbTNqCc4rdK1JG9Ie0EZMLAxAP1OxQOkcxEheiBGqfILQ51MMQWro1IimG+tg8FBTxO67Ag6+c5TD4BzLqt3R0versVqKY0BnksZaUe1WQ57q1ViJY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bR6EP4c2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bR6EP4c2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709123196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+8T7na7hLDlOY+fpWxEVATnNGHZl5MLIMw+pfcdigZo=; b=bR6EP4c2tjVfyxRnX/ZKK9ZygAQZwNtnsdJTweFmITdJryOD01RAG/vVMm4Gi7pjpJzJ5i M37iw9qWVX7gzzeMg8zSZACCT83qgx96BQqWISTtKFxjxufLWMLhnBH9XFs502YHlrLPHI jO1tTkOZ+H9vIhP7h1533l6aFnOIPxI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-BOHuYC_zNa-nq1ZE2WG5_Q-1; Wed, 28 Feb 2024 07:26:33 -0500 X-MC-Unique: BOHuYC_zNa-nq1ZE2WG5_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96A50185A782; Wed, 28 Feb 2024 12:26:32 +0000 (UTC) Received: from localhost (unknown [10.72.116.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF05610A58D9; Wed, 28 Feb 2024 12:26:31 +0000 (UTC) Date: Wed, 28 Feb 2024 20:26:26 +0800 From: Baoquan He To: Uladzislau Rezki Cc: linux-mm@kvack.org, Andrew Morton , LKML , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , "Liam R . Howlett" , Dave Chinner , "Paul E . McKenney" , Joel Fernandes , Oleksiy Avramchenko Subject: Re: [PATCH v3 07/11] mm: vmalloc: Offload free_vmap_area_lock lock Message-ID: References: <20240102184633.748113-1-urezki@gmail.com> <20240102184633.748113-8-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 On 02/28/24 at 11:39am, Uladzislau Rezki wrote: > On Wed, Feb 28, 2024 at 05:48:53PM +0800, Baoquan He wrote: > > On 01/02/24 at 07:46pm, Uladzislau Rezki (Sony) wrote: > > .....snip... > > > +static void > > > +decay_va_pool_node(struct vmap_node *vn, bool full_decay) > > > +{ > > > + struct vmap_area *va, *nva; > > > + struct list_head decay_list; > > > + struct rb_root decay_root; > > > + unsigned long n_decay; > > > + int i; > > > + > > > + decay_root = RB_ROOT; > > > + INIT_LIST_HEAD(&decay_list); > > > + > > > + for (i = 0; i < MAX_VA_SIZE_PAGES; i++) { > > > + struct list_head tmp_list; > > > + > > > + if (list_empty(&vn->pool[i].head)) > > > + continue; > > > + > > > + INIT_LIST_HEAD(&tmp_list); > > > + > > > + /* Detach the pool, so no-one can access it. */ > > > + spin_lock(&vn->pool_lock); > > > + list_replace_init(&vn->pool[i].head, &tmp_list); > > > + spin_unlock(&vn->pool_lock); > > > + > > > + if (full_decay) > > > + WRITE_ONCE(vn->pool[i].len, 0); > > > + > > > + /* Decay a pool by ~25% out of left objects. */ > > > > This isn't true if the pool has less than 4 objects. If there are 3 > > objects, n_decay = 0. > > > This is expectable. > > > > + n_decay = vn->pool[i].len >> 2; > > > + > > > + list_for_each_entry_safe(va, nva, &tmp_list, list) { > > > + list_del_init(&va->list); > > > + merge_or_add_vmap_area(va, &decay_root, &decay_list); > > > + > > > + if (!full_decay) { > > > + WRITE_ONCE(vn->pool[i].len, vn->pool[i].len - 1); > > > + > > > + if (!--n_decay) > > > + break; > > > > Here, --n_decay will make n_decay 0xffffffffffffffff, > > then all left objects are reclaimed. > Right. Last three objects do not play a big game. See it now, thanks.