Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7054843rdb; Wed, 3 Jan 2024 03:09:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEio6faO7D/x4aP1wMUtNzEY9qqpMdkuDzc+QrEdNvJGbUNVv4VcFEXUKrcNm2FHR3uY9zo X-Received: by 2002:a25:1e8b:0:b0:dbe:9f8d:5fc5 with SMTP id e133-20020a251e8b000000b00dbe9f8d5fc5mr453524ybe.10.1704280145721; Wed, 03 Jan 2024 03:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704280145; cv=none; d=google.com; s=arc-20160816; b=wtXvdAttNPIlzZNoiSOGyQwsqPUVRGI1UQXpBp8k8USAKBIJKc+i8X+Hn8Z6uYEg54 m5YJ7/hSgmaxNyPliz1o/WaU0UPqY+vprAU/f4wqTwedgs4qLvIelcB7OR+Me8X8CQKL UFUGl7grthY3PHFGygNvNIZZR9E7O/5CeltF7K+q7LMKeWOy0Wo4v4jNOeT0XIUq86AK prAeVvbaLPzg3hPuYrg+sP0JZBRiCCLSRM1V11DQFu7CE0B+27miRsl4WyLLoASjxXDx AJrqjgkiZ/aJb1NJHNhRLkcnsvfDFs3CLvqtRw+GIbmhkG16Rx5IbhaIDeiPQQu3jdvP raQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=iID84qWp2nm6Z238HqiONwumxN9PMO5mg9S2VquT7Dk=; fh=JPR4SrZevNUGs73ZaaemZ7nZxsztoURYXeelf8U//6M=; b=pCNdmmDiudUfCfMjuvcaRERcXg3QtHTKNY9lHc7zGDqo1kqzE653E3GJ8WMBsOogTC 0zyIS8lcPqAGSCOw4pCL3hus/W9y1rpyWSAdpYdm0TsOkKhSWhnNokUMwRHnZjsHUcgD F8H13KGyTfVUP7WTwucap7C2PDfjjHtsTUkm2irCgdrBwmMK3qbhY7FBuL2B1/RfL13P vq21FBxqZefcbjqO1uYc1FObc9cbRKadXvnaa0SlrGYwPlRy4w7Rvu3Mm+Ufl9LLM48S uju2ThkhTda0A7G9s4do6qzhV/FE0d5f62kiysLRQbdQHCZdEi6KgpEf5FK2XQg2BBym 3v/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15426-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u21-20020ac858d5000000b004259d9fde02si28407191qta.438.2024.01.03.03.09.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 03:09:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15426-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D0E11C2195F for ; Wed, 3 Jan 2024 11:09:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42E6F18E12; Wed, 3 Jan 2024 11:09:00 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail78-36.sinamail.sina.com.cn (mail78-36.sinamail.sina.com.cn [219.142.78.36]) (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 3065A18E07 for ; Wed, 3 Jan 2024 11:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.51.3]) by sina.com (172.16.235.25) with ESMTP id 6595403A000027EE; Wed, 3 Jan 2024 19:08:44 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 63296334210320 X-SMAIL-UIID: 439AB0640BED4853B1F70BFA8D665C00-20240103-190844-1 From: Hillf Danton To: "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, LKML , Matthew Wilcox , Oleksiy Avramchenko Subject: Re: [PATCH v3 07/11] mm: vmalloc: Offload free_vmap_area_lock lock Date: Wed, 3 Jan 2024 19:08:32 +0800 Message-Id: <20240103110832.2711-1-hdanton@sina.com> In-Reply-To: <20240102184633.748113-8-urezki@gmail.com> References: <20240102184633.748113-1-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. > + } > + > + reclaim_list_global(&decay_list); > +}