Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3886576rdg; Wed, 18 Oct 2023 08:42:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVexxptpBXI8ugkg5oGFWqewssvl2MEzvXRTpWWW+ZvJ7cY3EP32tyxC59SCX5vJ5dz9cZ X-Received: by 2002:a05:6a20:8e2a:b0:17b:3fe8:b4e1 with SMTP id y42-20020a056a208e2a00b0017b3fe8b4e1mr2768018pzj.50.1697643754645; Wed, 18 Oct 2023 08:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697643754; cv=none; d=google.com; s=arc-20160816; b=iEGwdRj76bWsU6o04K2wUszV79ubqM5B7nuGaCUqA1x6eGwVP5MQ9P+Ll5VSRRVo4E rSPMRoz4riZ1JhvxFOOsmPguwnO8zCuoinOhD56hUYloJgZdzizBXZe4ci1mC4upculS TdbQlvBviiKGGVbGO4JGv14d2FSuf/c6dPUj1lkqTd2s87zIjWy984jxgcxidnjIR1GY nu5RJ6uQLfSTjgs6Wbb00dTIs4q7y6tdMnh8tdZ5B3XyQzK8gh6WMMPfkOtfF2HBFHkk cIakpMfcdquidd47PKU9U+xEuTrw639YB5c4+Wm1y6SBZwqN/N8I47JxvazJlwhR2I3a k2Eg== 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; bh=Othonz4h54SeGIzH8u6iMsnnlBlisak2p+Huf9yyHgc=; fh=vJuql4DTq6KnxQZ/B563xy3AlrOr/OkDGOAqBtLkTrE=; b=s5lyAIyE4gTqZUKrNZxt/wycRZQMXuXpwVg8zaCE/k1mw6ZrK3GYswELHF2MiLTRkL tMtg5bCnjSA5t4KHdkelDM+/1oNracsROfKP/Jo2mR+Dy41yzvQbYobUlL92D8rz+pkQ mTfgU3udr/G+m0YvYoJl+COVqGXNgC9aTG1lyM1M0N0aFPjCbHgW+0xNQy2SyBdOmNLZ UEucihJv9UNLJ8O7WPQkN8DxJiIYsYjVe2uLWoNPYFRy7uWNe2cLXOu6Vie2l4Yvd4XA 9isYIAxm/j24jWC6W/vWEZ5BryE8Zb77AnBZjc3wKG/8bLHwP5qlwu6WDnuJ0gvFtVia t8lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q19-20020a17090a2e1300b0027762d9999csi50980pjd.155.2023.10.18.08.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 60EA78215795; Wed, 18 Oct 2023 08:42:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344744AbjJRPmT (ORCPT + 99 others); Wed, 18 Oct 2023 11:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232412AbjJRPmR (ORCPT ); Wed, 18 Oct 2023 11:42:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F2311B for ; Wed, 18 Oct 2023 08:42:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD0FC433C8; Wed, 18 Oct 2023 15:42:14 +0000 (UTC) Date: Wed, 18 Oct 2023 16:42:12 +0100 From: Catalin Marinas To: Liu Shixin Cc: Patrick Wang , Andrew Morton , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/7] mm: kmemleak: split __create_object into two functions Message-ID: References: <20231018102952.3339837-1-liushixin2@huawei.com> <20231018102952.3339837-5-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018102952.3339837-5-liushixin2@huawei.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 08:42:32 -0700 (PDT) Thanks for this, it looks better. On Wed, Oct 18, 2023 at 06:29:49PM +0800, Liu Shixin wrote: > -/* > - * Create the metadata (struct kmemleak_object) corresponding to an allocated > - * memory block and add it to the object_list and object_tree_root (or > - * object_phys_tree_root). > - */ > -static void __create_object(unsigned long ptr, size_t size, > - int min_count, gfp_t gfp, bool is_phys) > +static struct kmemleak_object * __alloc_object(gfp_t gfp) > { > - unsigned long flags; > - struct kmemleak_object *object, *parent; > - struct rb_node **link, *rb_parent; > - unsigned long untagged_ptr; > - unsigned long untagged_objp; > + struct kmemleak_object *object; > > object = mem_pool_alloc(gfp); > if (!object) { > pr_warn("Cannot allocate a kmemleak_object structure\n"); > kmemleak_disable(); > - return; > + return NULL; > } > > INIT_LIST_HEAD(&object->object_list); > @@ -649,13 +639,8 @@ static void __create_object(unsigned long ptr, size_t size, > INIT_HLIST_HEAD(&object->area_list); > raw_spin_lock_init(&object->lock); > atomic_set(&object->use_count, 1); > - object->flags = OBJECT_ALLOCATED | (is_phys ? OBJECT_PHYS : 0); > - object->pointer = ptr; > - object->size = kfence_ksize((void *)ptr) ?: size; > object->excess_ref = 0; > - object->min_count = min_count; > object->count = 0; /* white color initially */ > - object->jiffies = jiffies; > object->checksum = 0; > object->del_state = 0; I'd keep all the initialisation in one place even if it means passing more arguments to __alloc_object(). It feels a bit weird and error prone to split the initialisation in two places. Otherwise I'm fine with the split. -- Catalin