Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3995736rwj; Tue, 20 Dec 2022 04:56:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Im6VJF+RkZFerpJ77bVaoGbbOlhtBctWA1hKNhZCmTHgUb4vbuSnbyZP6ubwhPjHdTGBY X-Received: by 2002:a17:906:1150:b0:7c0:db53:c5ab with SMTP id i16-20020a170906115000b007c0db53c5abmr37518260eja.25.1671540982712; Tue, 20 Dec 2022 04:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671540982; cv=none; d=google.com; s=arc-20160816; b=etHwFoZCHhvPLRC3ioY/5FckGT/YMy8f7+P2hL8v9YaJEd1ElvlP0SzXp1DM3PYmPU +zwya+aUjBw+YMsjCOF17mIsTr8nK9++HyDX45kmYNx38wtibxHCgrdtBZqGRybvyMtQ oV195Sd0wf52g4cWkx1YMuBqwAlCIq8V1p9907i/MFB96P9KkEkCBC2kaIO43NdI7aEq YLMO7fVckcBqL95GzrVkRz8u3x07KA6idom5XaYnyZTPu8iV2V+yqPgzrIGp6y4SqYX8 p5sWUgG7hDJOSr52E1Mvh3S2MU+xJ7JuX7ZPZuYQ7+/Bqik186CZymYPFo/Q/gxAEXrC Q/MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rJJ50xWxBsBPwyj6/W9ULMCq+MmJKS8E+J4eWZ49RM0=; b=CfuNHgJzcP7XYBahPJk30BMZaNmRoUULIssWQYUbaeJUIS9UugTIHCLsSg1pWjOv9A VYKvhqfrm6z/+je84b7xFT5GoYUk1F7phbd039Ahyqg8CzlPAJFavAt/dplSmgIiS+HA 66MjNYC9+JtjmxhPwzZavQXHusDZGrCo4BUfphAHtPPQoTXRK8jk0OLyEbVrJDW05RgH +Xs/Nl/EvqMV+AQm6RZ3o4OEzV76YxAD81qygj8KrbwzAqKu5tUBmCI1vHVWPhzjfNwi 0058Yd2UFPhq7gMXGxtPdadBUffUS1TA+iSSUS2Esjo3nyyufw1jOe9jyGZFFR5fZhY0 j1xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gRE7Vr1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170906654500b007ae6e307f60si8437376ejn.323.2022.12.20.04.56.05; Tue, 20 Dec 2022 04:56:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gRE7Vr1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbiLTMpD (ORCPT + 70 others); Tue, 20 Dec 2022 07:45:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233527AbiLTMof (ORCPT ); Tue, 20 Dec 2022 07:44:35 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8622611C00 for ; Tue, 20 Dec 2022 04:42:12 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so11036536wma.1 for ; Tue, 20 Dec 2022 04:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rJJ50xWxBsBPwyj6/W9ULMCq+MmJKS8E+J4eWZ49RM0=; b=gRE7Vr1upbSZhXXMLbcosNUNhX1PT06NUozE5LUlXE6VLOKzu0aKzKD4gXWHPg0FDF cC1+Y0R+waXcwynCupEjzl8x3SVVqJOvu/f07vWHpRvxx6UJ223ZZKZd7YfdYWaeyDA/ 9FR7rtraBl2a+I/OCY4bUX6ht4J5WgTNXWmhGTcdON2H91wywpY6SkhXtSlEkQAshNyw 3RzfU16rlrAsGJcppdd5UpV1ogsQnruiftdcxP6HVmuLw4n/9eRvioir5CMcyGe8y4tQ SAuKrnNu4D9Cs6MvTTBPPs5U3HMoaKXerTnl/obaWCW9RWqO6x/vdhw5elMBGd8iktyn YvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rJJ50xWxBsBPwyj6/W9ULMCq+MmJKS8E+J4eWZ49RM0=; b=Ydy8xvThFDOtQNbg1J04cHPthVWaJuSD/PMr59Ghb9tN2i3G2a4aNPsUEtHR4P+23t QvhRe1OUZi/lES+G8QJKbCTN7tlGvIeMnR5ry3eataClS7Fi/8mhdzHaQ10pWe8fecCP Vvob8knrnrB443h0ilD9U8X9xQFbsan0rtTVFPOA6CeUOAXv9fSG8kIJUNT0P4oGhRk6 bdBbSU7pwBnuq9l19wrhJJ0ayarwKtyKCPZmlOSHsnBUj5wnV1cZajJzORKAibRHciRI EVICLy56wIOOxYa4gfdLVfXwe24yHkL3eVhQYX9KU/y8ZWkOfRbP7N7Mf2MlxOz04Hlb XxZw== X-Gm-Message-State: AFqh2kppLuPM1RNFPp8ywZ2u/7XIYZ8NW7x0CxM8U2EdqlSKumppKA8k j/uJVpf72P+DUB04FylXKHE= X-Received: by 2002:a05:600c:5118:b0:3d3:494f:6a39 with SMTP id o24-20020a05600c511800b003d3494f6a39mr10477772wms.16.1671540130665; Tue, 20 Dec 2022 04:42:10 -0800 (PST) Received: from localhost ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.gmail.com with ESMTPSA id k18-20020a05600c1c9200b003a84375d0d1sm25398750wms.44.2022.12.20.04.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 04:42:09 -0800 (PST) Date: Tue, 20 Dec 2022 12:42:09 +0000 From: Lorenzo Stoakes To: Baoquan He Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org Subject: Re: [PATCH v2 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Message-ID: References: <20221217015435.73889-1-bhe@redhat.com> <20221217015435.73889-3-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2022 at 08:14:15PM +0800, Baoquan He wrote: > Hmm, for the two kinds of vm_map_ram areas, their code paths are > different. for unmapping vmap_block vm_map_ram, it goes through > vb_free(). I can only do the clearing in free_vmap_block(). > > -->vm_unmap_ram() > -->vb_free() > -->free_vmap_block() > > For non vmap_block vm_map_ram area, I can do the clearing in > vm_unmap_ram(). > -->vm_unmap_ram() > -->__find_vmap_area() > -->free_unmap_vmap_area() > > As said earlier, clearing va->flags when unmap vm_map_ram area, or > clearing va->vm in remove_vm_area(), these have better be done. > However, not clearing them won't cause issue currently. Because the > old vmap_area is inserted into free_vmap_area_root, when we allocate a > new vmap_area through alloc_vmap_area(), we will get q new vmap_area > from vmap_area_cachep, the old va->flags or va->vm won't be carried into > the new vmap_area. Clearing them is a good to have, just in case. > Sure, this is more so about avoiding confusion and perhaps some future change which might not take into account that flag state could be invalid. I guess logically speaking, this is still a block when you are unmapping ram, so it's not unreasonable to retain the VMAP_BLOCK flag. In that case I'd say we're good simply clearing VMAP_RAM here. Thanks for the explanations! > Rethinking about this, I may need to do the clearing when freeing > vmap_block. Otherwise, people will be confused why the clearing is not > done. > > @@ -1815,6 +1815,7 @@ static void free_vmap_area_noflush(struct vmap_area *va) > > spin_lock(&vmap_area_lock); > unlink_va(va, &vmap_area_root); > + va->flags = 0; > spin_unlock(&vmap_area_lock); > > nr_lazy = atomic_long_add_return((va->va_end - va->va_start) >> > That sounds like a good idea!