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 4487EC38142 for ; Tue, 24 Jan 2023 13:18:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9755F6B0074; Tue, 24 Jan 2023 08:18:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 925066B0075; Tue, 24 Jan 2023 08:18:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C5686B0078; Tue, 24 Jan 2023 08:18:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 642566B0074 for ; Tue, 24 Jan 2023 08:18:06 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 32FF5140352 for ; Tue, 24 Jan 2023 13:18:06 +0000 (UTC) X-FDA: 80389745772.02.6EDC692 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id EB32DA0018 for ; Tue, 24 Jan 2023 13:18:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bM8zl4hg; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674566284; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U8FL2hCl9BWMQrve4jEgUposmmxHpM9LrhFavxYOcgQ=; b=LoI0ChvwBLD9bdAdq/RVVpDC+3luV1csr14aJCIO6S/p46irSG09S+H6zZvdKdMH06QCV3 8XVAPMTqs/CKAR8ks6WqmzLnBWWHqqvA2TI9Z+Llq7lth7+06FTObjly3DqyNIrYRsRZbw LC/GgVko0z5e4Jk9QZ3SNjM97n9t3TQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bM8zl4hg; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674566284; a=rsa-sha256; cv=none; b=arh9IZsTJWAJ/ihGsRRHYbdCcurbkGiRX9R1NF55GGCcvr2aKlFzhGKyx2oGYq5iVCCDIm cXJSHM80DlZsepG8l+drGJFOGwM27on+L0m/k+3hrQSyNuYlJhQWh3+AZNgdJ/ZvIErtr6 OmsUwvNlKTN1s4PIkrs7S68VJdHKv+Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674566283; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U8FL2hCl9BWMQrve4jEgUposmmxHpM9LrhFavxYOcgQ=; b=bM8zl4hg7FksKjDfEAbESQezHTE1MkKtc4nx7oXy80YNPHkYnvCcwwqQAa49kUWkKcY+rt fYael58MG7L787TcYGe2uRXUyM6tYspXzz8GTi9YVS2x3pT6Y0/RCh3uAeEggaoS99xaxj Vcbc6ZKvoeLobjsrJVQ4doM0L3mpRr0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-519-RxIVAqZ4N2ez7mZ1EwOp5A-1; Tue, 24 Jan 2023 08:18:02 -0500 X-MC-Unique: RxIVAqZ4N2ez7mZ1EwOp5A-1 Received: by mail-wm1-f71.google.com with SMTP id l31-20020a05600c1d1f00b003da8b330db2so670424wms.1 for ; Tue, 24 Jan 2023 05:18:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U8FL2hCl9BWMQrve4jEgUposmmxHpM9LrhFavxYOcgQ=; b=kcgkmlYZyOMxpxDpL52ku8onJCIlxNulmbW/333MMAgH37pqpkTYLdDQzzqpnlZuiE 0KL6HEfukEiXRIR/qS+gRk3rfgFW1CZaUnE25boeLt/KOPl4jJe1+gOyseH/V4Wtvm9Z SOihLQ9mq/5nSyfIDaPQzT8OzhmjdnV07WocSdfIJfUFzt8oTWZnP2aYtyDL5H4pedxt wEK21CgXvxIsic7lTIcpBE3HqCVwQTsFX4FHSV5IhAaKIyBv1HN/zaLnWCK53H7UHZ81 nZ0r8PzEFt4Y9pZ47V/xxeL9zDJ3qUI9hsKoZ1NcPALnLp1+6rARrzvRxUNpzfErFyMa P0zA== X-Gm-Message-State: AFqh2kqS4to9ghnABv2qvPwl7RyvaT9adJW0JSVo0W+kDSTD/9ildj3N 5IePBZzMqf9jynK/ca8oN+EvL3zU9nkSJlQAXtQaCtTeclRXSk8e4HSMicx2EH7jSbQvS9y1rwX RXq+t8UEourE= X-Received: by 2002:a05:600c:35d5:b0:3db:fc4:d018 with SMTP id r21-20020a05600c35d500b003db0fc4d018mr25273875wmq.40.1674566280754; Tue, 24 Jan 2023 05:18:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXTM8iTQEaYS8uGn/qwNJ8FB0rJLsepjJozYAsBeZMjmKElS3iKMDkFvVcz+xTltH0ta5v8w== X-Received: by 2002:a05:600c:35d5:b0:3db:fc4:d018 with SMTP id r21-20020a05600c35d500b003db0fc4d018mr25273849wmq.40.1674566280391; Tue, 24 Jan 2023 05:18:00 -0800 (PST) Received: from ?IPV6:2003:cb:c707:9d00:9303:90ce:6dcb:2bc9? (p200300cbc7079d00930390ce6dcb2bc9.dip0.t-ipconnect.de. [2003:cb:c707:9d00:9303:90ce:6dcb:2bc9]) by smtp.gmail.com with ESMTPSA id e6-20020a05600c2b4600b003da2932bde0sm2393864wmf.23.2023.01.24.05.17.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Jan 2023 05:17:59 -0800 (PST) Message-ID: Date: Tue, 24 Jan 2023 14:17:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] maple_tree: Remove GFP_ZERO from kmem_cache_alloc() and kmem_cache_alloc_bulk() To: Liam Howlett , Mike Rapoport Cc: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Jirka Hladky , Matthew Wilcox References: <20230105160427.2988454-1-Liam.Howlett@oracle.com> <20230106183559.mpdywid4szzpghlk@revolver> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230106183559.mpdywid4szzpghlk@revolver> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EB32DA0018 X-Rspam-User: X-Stat-Signature: ufw49rrtmxbx19fd7zsz1yjauyayotaz X-HE-Tag: 1674566283-668101 X-HE-Meta: U2FsdGVkX18PEU69cZRrjeIeyBamDe+fIp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54fQB+pnfajsgSHkg8Nl4IDqICdhqmLa+lhq3hAuGXw8OMCN6kv6SvQ3NpLJB1PElHzzcSplwKOH1RsLqmB5teh1f1o7aURXpgSEKqwYWdttd9LquXjknYcq7cZRZvp5ZvwaF1kDh/HBDCcNngJEf9GifSWly3N9FbRm84c5sN28tIkOVoYnSVIrGc1d0UeTIoZH/zpcLEpcUlB9niB8VY9wBWul7DDbn2RTbwpSXAAonGsCh4FCKbFBHgs6iYO7V9qqy/GZc3F9yJBXQYwmbDcNZATqdIvxQR7mJeV6Y4MPMQrQSJEHrlP5+Y2qC/nzQNeQOY3AwQobj2/XyjTEF038OEtVzDV70DKpqup0b0WGH9n62jHmAtKea4XkpyJa+9nuJZyezq8BqLfSi7Auxd8GZU/xGUeor4XmT0dxlJQaZvUIhTQ8gJcVkoXUXJMvFM9caMNwR4R6C3efprJ/Qwd1q+x/Fm+J1gJqI0yj25yjUL6L59TuNKkDVMTFUEe8Ej/Dw/8Htj1f2IQj6sU9BQA2e7tNnpH8mAOowA== X-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 06.01.23 19:36, Liam Howlett wrote: > * Mike Rapoport [230106 02:28]: >> On Thu, Jan 05, 2023 at 04:05:34PM +0000, Liam Howlett wrote: >>> Preallocations are common in the VMA code to avoid allocating under >>> certain locking conditions. The preallocations must also cover the >>> worst-case scenario. Removing the GFP_ZERO flag from the >>> kmem_cache_alloc() (and bulk variant) calls will reduce the amount of >>> time spent zeroing memory that may not be used. Only zero out the >>> necessary area to keep track of the allocations in the maple state. >>> Zero the entire node prior to using it in the tree. >>> >>> This required internal changes to node counting on allocation, so the >>> test code is also updated. >>> >>> This restores some micro-benchmark performance: >>> up to +9% in mmtests mmap1 by my testing >>> +10% to +20% in mmap, mmapaddr, mmapmany tests reported by Red Hat >>> >>> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2149636 >>> Reported-by: Jirka Hladky >>> Suggested-by: Matthew Wilcox (Oracle) >>> Signed-off-by: Liam Howlett >>> --- >>> lib/maple_tree.c | 80 +++++++++++++++++--------------- >>> tools/testing/radix-tree/maple.c | 18 +++---- >>> 2 files changed, 52 insertions(+), 46 deletions(-) >>> >>> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >>> index 26e2045d3cda..82a8121fe49b 100644 >>> --- a/lib/maple_tree.c >>> +++ b/lib/maple_tree.c >>> @@ -149,13 +149,12 @@ struct maple_subtree_state { >>> /* Functions */ >>> static inline struct maple_node *mt_alloc_one(gfp_t gfp) >>> { >>> - return kmem_cache_alloc(maple_node_cache, gfp | __GFP_ZERO); >>> + return kmem_cache_alloc(maple_node_cache, gfp); >>> } >>> >>> static inline int mt_alloc_bulk(gfp_t gfp, size_t size, void **nodes) >>> { >>> - return kmem_cache_alloc_bulk(maple_node_cache, gfp | __GFP_ZERO, size, >>> - nodes); >>> + return kmem_cache_alloc_bulk(maple_node_cache, gfp, size, nodes); >>> } >>> >>> static inline void mt_free_bulk(size_t size, void __rcu **nodes) >>> @@ -1127,9 +1126,10 @@ static inline struct maple_node *mas_pop_node(struct ma_state *mas) >>> { >>> struct maple_alloc *ret, *node = mas->alloc; >>> unsigned long total = mas_allocated(mas); >>> + unsigned int req = mas_alloc_req(mas); >>> >>> /* nothing or a request pending. */ >>> - if (unlikely(!total)) >>> + if (WARN_ON(!total)) >> >> Hmm, isn't WARN_ON() here too much? > > I don't think so. If we get to the point of asking for a node while we > don't have any to give, then it's too late. It means we (I) have > calculated the necessary nodes incorrectly and we won't have enough > memory to fit things into the tree. It should never happen. Either way, the suggestion is to use WARN_ON_ONCE() instead of WARN_ON(). ... now documented in Documentation/process/coding-style.rst -- Thanks, David / dhildenb