Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp261657rdb; Thu, 30 Nov 2023 04:21:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQXWm0pSC02BmXeCzgbahJoOZjVuNdm2ylnsuMFa9iibWp6V02s6FJhN1RTKRkYXHXLS0k X-Received: by 2002:a17:903:1212:b0:1cc:70dd:62c3 with SMTP id l18-20020a170903121200b001cc70dd62c3mr22588109plh.30.1701346893782; Thu, 30 Nov 2023 04:21:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701346893; cv=none; d=google.com; s=arc-20160816; b=jjP9aEsoXw1X8AsW5uauaff27e76uuZL79hIiRTIWfIAyeQkqX5QQ6ebOQozWdDW4R TDMjnvc+eu7EBhjNIGM+qcNIBcXzDevNN66ReOFZJioRnt6wQEMqcdDr8HBe9NCbl0wZ jxNVub88eOGfam6kMumWArcHV/WcVFTYCzAn9X8Z3wqhXMBRdQh8+hI/BYjcAYz2ptEh 1iQENm/Fn+/vvEUzjNF8NkhciDOamNHvYS4JyK7winO1sRuieHMJDbzW+2MD+12cnh5K +R9g40eBRyf3w8AZ5YUrJdtm1ZTkz0FFF2dvF+3CnEJfP2EAPqDlKpHEL804Ib9+NMoL 7Bog== 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=6tJIz4e3JyFdBhtkzwycUoa7SMsO3VCjY+FW8/96VJY=; fh=QBNv4YCHFU03eyzBx/tE2lTYVKmrwxK4pVYI4bovt1U=; b=Y53OP50ZE5JAv8MHSYLno8AS3h+EsLMYFwUf49wRGPKw4aCxEcYItF8Vv7WK5B3Bo3 OxLSnM3SE/smoZ+/S7sR8K2Fo4K+a8p4K3+vqAdKfum66qG8140dwGVZ73RmTC6ObWN0 OWtUQ/hVEe57pInvybGDICySJil7J6jN23weMeIzap6mtle78LGEhRmEBIQfXXmQ+fkH kSL0THHzFEACQjPr9GWubwFl1te1AJDjNngw1b6xOkmyffYZHCcy1jYW9RKPqjKGOtJb kdm7/R0KS9m8gEKmqYb82hFdfjTnmhSoiGQQw+EcweCTiVDHmJBRIFA4LomYl8RbAjG+ VN6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l4-20020a170902ec0400b001d0107e765bsi1045125pld.564.2023.11.30.04.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 04:21:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id C05E38083AC9; Thu, 30 Nov 2023 04:21:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbjK3MVB (ORCPT + 99 others); Thu, 30 Nov 2023 07:21:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345191AbjK3MU5 (ORCPT ); Thu, 30 Nov 2023 07:20:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8FD69A for ; Thu, 30 Nov 2023 04:21:03 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EDAAC433C9; Thu, 30 Nov 2023 12:21:02 +0000 (UTC) Date: Thu, 30 Nov 2023 12:21:00 +0000 From: Catalin Marinas To: Waiman Long Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/kmemleak: Add cond_resched() to kmemleak_free_percpu() Message-ID: References: <20231127194153.289626-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Thu, 30 Nov 2023 04:21:18 -0800 (PST) On Wed, Nov 29, 2023 at 05:57:11PM -0500, Waiman Long wrote: > On 11/28/23 11:04, Catalin Marinas wrote: > > The problem is looking up the object tree for each per-cpu offset. We > > can make the percpu pointer handling O(1) since freeing is only done by > > the main __percpu pointer, so that's the only one needing a look-up. So > > far the per-cpu pointers are not tracked for leaking, only scanned. > > > > We could just add the per_cpu_ptr(ptr, 0) to the kmemleak > > object_tree_root but when scanning we don't have an inverse function to > > get the __percpu pointer back and calculate the pointers for the other > > CPUs (well, we could with some hacks but they are probably fragile). > > > > What I came up with is a separate object_percpu_tree_root similar to the > > object_phys_tree_root. The only reason for these additional trees is to > > look up the kmemleak metadata when needed (usually freeing). They don't > > contain objects that are tracked for actual leaking, only scanned. A > > briefly tested patch below. I need to go through it again, update some > > comments and write a commit log: [...] > The patch looks reasonable to me. It also has a side effect of reducing the > # of kmemleak objects to track especially for system with large number of > CPUs. Of course, we still need more testing to make sure that it won't break > anything. Thanks for having a look. I'll tidy it up and post today or tomorrow. It can stay in next for a bit before upstreaming to get some exposure (though not sure many test -next with kmemleak enabled). -- Catalin