Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3124452rwb; Mon, 16 Jan 2023 04:08:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCUYib5A/0VIplprvKqnT2gDvg1/OyaoO1N1hgCqsN1gH9J1ihxnd5N4eAA4xm9OgbMMpv X-Received: by 2002:a17:907:72d3:b0:7c0:fd1e:972e with SMTP id du19-20020a17090772d300b007c0fd1e972emr103713022ejc.46.1673870924841; Mon, 16 Jan 2023 04:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673870924; cv=none; d=google.com; s=arc-20160816; b=CO4eMsD2uAPc+HEQOU0gU3LB8xMoTtQ9IHDqn6z0gQjFHsb41YQAHldWRjlzkNECS3 RQjVkgMP/6ZeZCcamgTs9FDdMGpv0B2lWLt9gbif+DQPmFQPKsXJp9fouukxKGR+x4mj rXdr2qSp9tzzhmnGIpnjfgndxEnSiPMmH5Dakb5yjXg4bpWzh2JGuqioWRsQDgrlCbgp Xjg/OGyGZW3+iXGBqvfG8b8tWy09/E7eKCq7bSnpZdMWZmdjdMmlQoenSwS4UyN1Rgl3 +ZVRLZ/osqgOTEsZ/fQRyummzuz8cAxuQAgviaOd9UYLybqZrz1Z1ve3gWKVSOehn6DM tLZw== 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:date:from:dkim-signature; bh=WW+GdQuvnNnKm/U4vO+vCnOCQLrE79/XGPwNYhmpQik=; b=RAwoofbP0Z5DLC3HZb9o23wJx39ma9oF1YWCE4demSeenE6Qis3AQsdA7QqEHr/B+i PTAMWoE42N/51Wexg83Js5JLH1fHnowucwEFOMoqdezIszW0MCU3ZT0rvt6blspHw4Xp cFEw0XqO+NHqFPdt8pfhz7uCrB8o5I/RYnZhd9QeKGRjNmD1kpo0Ma3I9+1kWHFJ60iJ RnhJ23XLCfcZx2BbgemWPNGoFUsuRzFspZ/O/l/SCo+fnyfptiRyNWCTdtjkuN8SbHrl M0dlYPvCNWWR2Cvu2oE3RBlhWz3bsEmw8su+vJtY1dP3xT+BDACnOSMB5dDXPpmXkgil lj5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ALG6KyeB; 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 he17-20020a1709073d9100b0078def5c29e3si34781731ejc.596.2023.01.16.04.08.32; Mon, 16 Jan 2023 04:08:44 -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=ALG6KyeB; 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 S229608AbjAPLu7 (ORCPT + 51 others); Mon, 16 Jan 2023 06:50:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjAPLuz (ORCPT ); Mon, 16 Jan 2023 06:50:55 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A9D558C for ; Mon, 16 Jan 2023 03:50:54 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id j17so42392166lfr.3 for ; Mon, 16 Jan 2023 03:50:54 -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:date:from:from:to:cc:subject:date:message-id:reply-to; bh=WW+GdQuvnNnKm/U4vO+vCnOCQLrE79/XGPwNYhmpQik=; b=ALG6KyeBBO+EAxG/y7g2nLAT+M09WHeqe4zvSaVz94dDYLHEb5YV7JFHVdh14ziGnG Kmk9HvT6NUsvly3g2fRh5XmvRo5AXIvfzKJRiAMnyWXpsCDkVlT79pkW9F3cKR/++ZyW Z/XKUJxpjhgzlF4i/UfE1PP7Hpn/jRfLg1Lyn90fRLoU9392Hh8Mad5hEe8p0RNBAM2g ZrWIg+XHaEnnSMPXib/OHoRqsRvcqVTa2julJdMtb4SWsgsd9FoyxlwLVQ8Ey0rJn+0/ uSjpsdf3a5op1vYjxfa6O3OuWriDDpn2ptqhjeo7pGEm6x7WgOs9cLePCrUFBWXcHwYu VGVw== 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:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WW+GdQuvnNnKm/U4vO+vCnOCQLrE79/XGPwNYhmpQik=; b=q9YPpc4mQvtZAVtGv2mYMEp0xBNItHaJiAd0WrHWTgyD94WV/CJlluJAgVa6hwNanM ltZn4QFxcOrwbtJCMvTTymUKxhma2TTNL1cNmYZ7cYP0OwkN7HAQy71c0kX3Ad/6mw+s dwLlSsz0kQrrMU0tUAkSTaDb5H6ur1HPBIvvxId+ptd0qK7Lx/csIBmv3hsabkjcxq5C EbZxFiV00YX7/8PaL6XmvE9aXeRAjbrbo1Nzw34W1uVaqKPHGzOPR47WpNP5w3dXsvBK oyklO0EqY7S2kj1J4IG2lLQ7pht76hDdNotfQYTVwqHwPzibFLq97Xy1y/a1d41NbSVn p3Gw== X-Gm-Message-State: AFqh2krTIff/FwXax5AlHI5tTeXO7twcduMnpSOPd/3RN3nGiFfCJBPY VVhjH4wEYjEtp2qn4htlV7Y= X-Received: by 2002:ac2:42c4:0:b0:4a4:68b7:d645 with SMTP id n4-20020ac242c4000000b004a468b7d645mr20859265lfl.44.1673869852773; Mon, 16 Jan 2023 03:50:52 -0800 (PST) Received: from pc636 (host-90-235-24-7.mobileonline.telia.com. [90.235.24.7]) by smtp.gmail.com with ESMTPSA id c15-20020a056512238f00b004cb3fbc7925sm4967081lfv.77.2023.01.16.03.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 03:50:52 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 16 Jan 2023 12:50:50 +0100 To: Baoquan He Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org Subject: Re: [PATCH v3 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Message-ID: References: <20230113031921.64716-1-bhe@redhat.com> <20230113031921.64716-4-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230113031921.64716-4-bhe@redhat.com> 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 Fri, Jan 13, 2023 at 11:19:17AM +0800, Baoquan He wrote: > Currently, vread can read out vmalloc areas which is associated with > a vm_struct. While this doesn't work for areas created by vm_map_ram() > interface because it doesn't have an associated vm_struct. Then in vread(), > these areas are all skipped. > > Here, add a new function vmap_ram_vread() to read out vm_map_ram areas. > The area created with vmap_ram_vread() interface directly can be handled > like the other normal vmap areas with aligned_vread(). While areas > which will be further subdivided and managed with vmap_block need > carefully read out page-aligned small regions and zero fill holes. > > Signed-off-by: Baoquan He > --- > mm/vmalloc.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 73 insertions(+), 7 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index ab4825050b5c..13875bc41e27 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3544,6 +3544,65 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) > return copied; > } > > +static void vmap_ram_vread(char *buf, char *addr, int count, unsigned long flags) > +{ > + char *start; > + struct vmap_block *vb; > + unsigned long offset; > + unsigned int rs, re, n; > + > + /* > + * If it's area created by vm_map_ram() interface directly, but > + * not further subdividing and delegating management to vmap_block, > + * handle it here. > + */ > + if (!(flags & VMAP_BLOCK)) { > + aligned_vread(buf, addr, count); > + return; > + } > + > + /* > + * Area is split into regions and tracked with vmap_block, read out > + * each region and zero fill the hole between regions. > + */ > + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); > + > + spin_lock(&vb->lock); > + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { > CPU-X invokes free_vmap_block() whereas we take the vb->lock and do some manipulations with vb that might be already freed over RCU-core. Should we protect it by the rcu_read_lock() also here? -- Uladzislau Rezki