Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2519444rbb; Wed, 28 Feb 2024 04:38:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZFvCscqEa00YQgKFj+8z8pA5eT+JXTGIW5xnGCV3MnobRgbQHiBEm/Gxk3/4pFeSjVD3fKVPPj+FPC6p9UrjEzW/zHUZ7Nbbusk43vQ== X-Google-Smtp-Source: AGHT+IEPaDBIma7jrFx3CvP+HJ9pqOfRP6MOJWF5C0D9bE0cwyexn6O5jtk6TRwSp153InNRccvb X-Received: by 2002:a05:6808:201c:b0:3c1:b34c:d691 with SMTP id q28-20020a056808201c00b003c1b34cd691mr3620003oiw.22.1709123911442; Wed, 28 Feb 2024 04:38:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709123911; cv=pass; d=google.com; s=arc-20160816; b=RUp8VWh5gwop8hgK818NFoXvB2CJXRumejnI8UfaEYplC7e3RuDsrPUUjhV+Nns/6X rHyokILDLH1gMA56DbVEGdSHpzeRVB+AEZ5SMvIFsOzoMIR9wsBjLaNpicE6YmJLaojM aMxNn4v8vZV/uohYP0b7ydRkbdZbl/U780f2U8fzs1YSR9R5iItPfFQV2+CHDyRvuFlj dtIcR2kJDgqfBuNaC8jlZtTpUeiCTzXWCk81VdFFT16Di19YitzmQk+T0eIChK/TlVnJ QZNPK60XJn0jTQmycrJ4ysuLPBn1t2qs5bN1X+nKY0GCmxi06XcTTk3J2Ss2qdpNtJ8e L2WA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+8T7na7hLDlOY+fpWxEVATnNGHZl5MLIMw+pfcdigZo=; fh=slJMzQ1RvrZUOlfD2500Kf4ZO6ZGA+3mv2ASwoAyUK4=; b=sMuviRkN4fA8yTliQFM3FTFanjveJh514NdgXvsw8zSe46juPW8Y0LczZUY/GVnrYi diGKaAYRNw+0RxY2WUNp711th/QTayUV08Oh2km85+BDV+uM6T3Rt4Ma7AwyHTw/0EbO QgUEbplCjR3TZi9YvsrB6gwHLKO2N7tfUGvUKSRhduyig2HdAaD0eEFunhaFXLnyr4Xu nUUHvHjUQCQ3y39NOv0TVKrUgOfdLFOlm7AH/ZZ/mNW+bzAUWVOOwIQQVb97VwTPq1j0 IuRcl63cFacE9cFv4DLAAvpegyQHV+V271gk2BrSihaiYTxdphYbPEOOCvS4+LTUzz4s DZiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bR6EP4c2; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-85010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id fe21-20020a056a002f1500b006e05b7bfcffsi7237257pfb.52.2024.02.28.04.38.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 04:38:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bR6EP4c2; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-85010-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DE069B214AB for ; Wed, 28 Feb 2024 12:26:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 294543BBDB; Wed, 28 Feb 2024 12:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bR6EP4c2" 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 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.