Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7200291rdb; Wed, 3 Jan 2024 07:48:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBz5SzafgtHW7ydbREl3TxMQlsVoThKld62R7dCb7WNrSFVirWRboTNQU3R34UE62hRkC0 X-Received: by 2002:a19:f812:0:b0:50e:6c1d:5dec with SMTP id a18-20020a19f812000000b0050e6c1d5decmr4280324lff.23.1704296888999; Wed, 03 Jan 2024 07:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704296888; cv=none; d=google.com; s=arc-20160816; b=cVtGxBt/1j05XQ7UP7QroQkBeq3eyp4RNVfge4cNq8qLaj4okPf3UOx7LSZOV+i6km 3dD3cFunvDQ5MY4eRDl7Ij2yuq1v9B5OSjhAxEpQWj8fZ4KXks4jxU4zI6j1fGK6djvp APB7M4unC3CwK9CttpeDXIy2+/zRPcxkR13tkyrfom9f+NQlFI6CJE6WL9DHR92ww0Ph 9tv71ryyJNtTjKL04YQnrecZZGAszZ4PS/sXV3gg8TmDeHkxKYkRWwX2tmAOiGcHiOhI jX21I8V8CIT84m9pD4he50JWn7l7MPSKuWu2wGXGh/p/rc3lMtn83yYwiYEdemSBFJia 89lg== ARC-Message-Signature: i=1; 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:date:from:dkim-signature; bh=hhrsogcA78u+i7VN1yFSxBLITouejwykBZ4THZ1vf8s=; fh=yQgKeOZkmqN6ZrGzvrcegac/HpPi8fvvM+df8jMaXiI=; b=cmd7XkLFqP2kEzVqMSxG1qvvnTEKpHRAHIBpF8aojieZXiCi2wKbR22DlGM2IzB8DG MLeXiJwv5LqBMPfxQUmmT1qp8BpDC7UzHIlzySjiK0yVZ0iUw0rtXSBJtBedQG3cMO2/ Dz107rlS365dw+xwwsJrMZRlSqBRbAiAAaLnwBRkrCakIKjQg6l358zIyKPad5M7W1S5 oBEdB5jOK4b3z/i2UOMSjffZ/U/qmjF+MBZ2T7bJutyqwYPUw4c2KmW6cakZhc6byQ5r 4p/pp3tKhGWUbMZfvTPtQibCjleb76AibM74+ArrB0vKTLri04U3wbuYB8WPnsiAhHLT gbnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="I9A/EMsT"; spf=pass (google.com: domain of linux-kernel+bounces-15714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dm6-20020a05640222c600b005556ee9a747si6109129edb.163.2024.01.03.07.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:48:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="I9A/EMsT"; spf=pass (google.com: domain of linux-kernel+bounces-15714-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id B499A1F24902 for ; Wed, 3 Jan 2024 15:48:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 749171BDFC; Wed, 3 Jan 2024 15:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I9A/EMsT" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 2320B1BDE3 for ; Wed, 3 Jan 2024 15:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2cceb5f0918so46120751fa.2 for ; Wed, 03 Jan 2024 07:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704296845; x=1704901645; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=hhrsogcA78u+i7VN1yFSxBLITouejwykBZ4THZ1vf8s=; b=I9A/EMsTKRwzLN+AkQrngzfmllaOi2wtFXuw8tcGBlTRLzqJsm35qHauSoHpTk4fh3 ZDfT1jigGem9DnIbkMOcAvCOggdZw0CoEaqNlJg9HhQgb4/ISywRFHvS8Bg7ALkKinim eM+BBqTgosEteRSmjm7tQZ9ezxHJfc0cpm7lMxPLDP2wJZRFc915uRK726iypPoos+4K jEJlgxyQ/1ptO5bh4VvDA1EbLf97LGVQgYWE/rAnkC60+pZ9JBl4NCvuN0vQL8i3dxVl GqNYyrUz14vUXec3r4keePmNxLhTz8FQcYRyDpatKjz/htAtJf/ZgfzGIlG8arsmCMgh E8Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704296845; x=1704901645; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hhrsogcA78u+i7VN1yFSxBLITouejwykBZ4THZ1vf8s=; b=rCQ12JnofJKosiBJI2wy1vhuu5pY80CZ/ZAu9WLL1byqlzkCuItstwoPwlN77LJejx HiMKrykZyiIk32SsyIiGjrAS16nWRi3W5iEXMmO411vqiNa9lqL6YNXSw70ZLH2yqvyW 7oab+YiwAsH6wN97um5YAEp4OuHe+C25RiMakO/9Y7WeD4ZfXDFFsoe7ayls1OZDw6y/ iUJaQhhheuwNECFiVo+MBdAbOwHLd8TUQnbtqpk1f5f/jVpzuxMJQLkL9oEeL7Bsw7y0 k+NWB2+MSeZAl0B+ySMMukD7MUQjEvO8m/C3vp9V0vHkeLa1U5+D5E15feaIv6mCnC0Z 8X5Q== X-Gm-Message-State: AOJu0YzyjOp0i/sWP7vJokJecTO8sfVv+qw6sZ1bay81i474uWxKGmQw clRARwnmWbUebiquV3ns+77EMIg5uk4= X-Received: by 2002:a2e:a585:0:b0:2cd:348:94a6 with SMTP id m5-20020a2ea585000000b002cd034894a6mr1551015ljp.92.1704296844737; Wed, 03 Jan 2024 07:47:24 -0800 (PST) Received: from pc636 (host-90-233-200-64.mobileonline.telia.com. [90.233.200.64]) by smtp.gmail.com with ESMTPSA id s10-20020a2e81ca000000b002ccd39eeae4sm3518354ljg.100.2024.01.03.07.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:47:24 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Wed, 3 Jan 2024 16:47:22 +0100 To: Hillf Danton Cc: "Uladzislau Rezki (Sony)" , linux-mm@kvack.org, LKML , Matthew Wilcox , 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> <20240103110832.2711-1-hdanton@sina.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: <20240103110832.2711-1-hdanton@sina.com> On Wed, Jan 03, 2024 at 07:08:32PM +0800, Hillf Danton wrote: > On Tue, 2 Jan 2024 19:46:29 +0100 Uladzislau Rezki > > +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. */ > > + 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; > > + } > > + } > > + > > + /* Attach the pool back if it has been partly decayed. */ > > + if (!full_decay && !list_empty(&tmp_list)) { > > + spin_lock(&vn->pool_lock); > > + list_replace_init(&tmp_list, &vn->pool[i].head); > > + spin_unlock(&vn->pool_lock); > > + } > > Failure of working out why list_splice() was not used here in case of > non-empty vn->pool[i].head, after staring ten minutes. > The vn->pool[i].head is always empty here because we have detached it above and initialized. Concurrent decay and populate also is not possible because both is done by only one context. -- Uladzislau Rezki