From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23215EE14A9 for ; Thu, 7 Sep 2023 00:06:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FD918E0017; Wed, 6 Sep 2023 20:06:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AE828D0005; Wed, 6 Sep 2023 20:06:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3756A8E0017; Wed, 6 Sep 2023 20:06:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 263E48D0005 for ; Wed, 6 Sep 2023 20:06:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E70A2160F01 for ; Thu, 7 Sep 2023 00:06:21 +0000 (UTC) X-FDA: 81207859362.05.88F9496 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 2E7F3100034 for ; Thu, 7 Sep 2023 00:06:20 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g77Sxpq5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694045180; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BgN4XRZyMzqcGmPmG5KWJX1UvABl/ETPX1t8ADqiNNc=; b=XZCytV1fOVZDdKSIigktah09HWVTvK1fxpqdZFC3F8ATRpTVZlNPxmK+Hh6ux1G+jzSvE+ l5/ptMRmqk06vaJoABLK2LkC6DU9JpH81EzxpDrgK1ENTAHVjYELJX8/3voP/RlrSzAvRF 1XUXG/7WmelleJ7tkkq6KJ4CMmIRebs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=g77Sxpq5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694045180; a=rsa-sha256; cv=none; b=hbQsOXvnf3t8r5wmJS/X5DpErUqjngmHeeDGMeSmNOrW3eGp8i8n1fILN37ubid5ZGA/NT IUHaa12+qFbhC7aZPuWuU6OB86bPhbwqAnKbbhAJsFzpPEQlyfZsAq6C8GH6iyIjtVTOS2 Wbw/cPHuPVsyo5XxvsyWSrfXhj5+Ul4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694045179; 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=BgN4XRZyMzqcGmPmG5KWJX1UvABl/ETPX1t8ADqiNNc=; b=g77Sxpq5+VbuQbOfUfUuxnmIw7Tv/oy8xD7TFKT2hGaFtERQyakfuF5XQqUZQWF7FQ6EnK Y3Geo+/l/2KMHsbxp4mZJP2r/H3yIpvwndpzZA+VSa0/Ky2JMylGgCXENlrlJXYrBN4niu gR9vS93OrsJLeF6Gft+FaNwSimb+39s= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-w_-2c7LON2eYF4e7Gf6ofg-1; Wed, 06 Sep 2023 20:06:14 -0400 X-MC-Unique: w_-2c7LON2eYF4e7Gf6ofg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F0263810D4B; Thu, 7 Sep 2023 00:06:13 +0000 (UTC) Received: from localhost (unknown [10.72.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2F7A40C2070; Thu, 7 Sep 2023 00:06:12 +0000 (UTC) Date: Thu, 7 Sep 2023 08:06:09 +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 v2 6/9] mm: vmalloc: Offload free_vmap_area_lock lock Message-ID: References: <20230829081142.3619-1-urezki@gmail.com> <20230829081142.3619-7-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2E7F3100034 X-Stat-Signature: forw4rfj8r9qoekqqa41nkhrxiqpet7s X-HE-Tag: 1694045180-978801 X-HE-Meta: U2FsdGVkX1/Yen2heSl2+7qgax0rwhHsFLah4LXQPqeAbv0Dte44iCRmykSMT+S83uqFp+8c382LDxQPCntP9feWggbcElKxhPTuMI8muw7mNNrkd1qkehJSc1pvUu1Tf1/2kfAw9ycrSqwW2Er8F2cT6p26kfqzBZi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Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 09/06/23 at 09:16pm, Uladzislau Rezki wrote: > > > static void free_vmap_area(struct vmap_area *va) > > > { > > > struct vmap_node *vn = addr_to_node(va->va_start); > > > + int vn_id = decode_vn_id(va->flags); > > > > > > /* > > > * Remove from the busy tree/list. > > > @@ -1594,12 +1629,19 @@ static void free_vmap_area(struct vmap_area *va) > > > unlink_va(va, &vn->busy.root); > > > spin_unlock(&vn->busy.lock); > > > > > > - /* > > > - * Insert/Merge it back to the free tree/list. > > > - */ > > > - spin_lock(&free_vmap_area_lock); > > > - merge_or_add_vmap_area_augment(va, &free_vmap_area_root, &free_vmap_area_list); > > > - spin_unlock(&free_vmap_area_lock); > > > + if (vn_id >= 0) { > > > > In alloc_vmap_area(), the vn_id is encoded into va->flags. When > > allocation failed, the vn_id = 0. Here should we change to check 'if > > (vn_id > 0)' becasue the vn_id == 0 means no available vn_id encoded > > into. And I do not get how we treat the case vn_id truly is 0. > > > > va->flags = (addr != vend) ? encode_vn_id(vn_id) : 0; > > > Yes, vn_id always >= 0, so it is positive since it is an index. > We encode a vn_id as vn_id + 1. For example if it is zero we write 1. > > If not node allocation path or an error zero is written. Decoding > is done as: zero - 1 = -1, so it is negative value, i.e. decode_vn_id() > function returns -1. Ah, I see it now, thanks. It would be helpful to add some explanation above decode_vn_id() lest people misunderstand this like me?