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 X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8026C433E2 for ; Tue, 8 Sep 2020 23:32:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 101D120936 for ; Tue, 8 Sep 2020 23:32:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="fjSVHbuk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 101D120936 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19C5D6B005C; Tue, 8 Sep 2020 19:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14C9D6B005D; Tue, 8 Sep 2020 19:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 061666B0062; Tue, 8 Sep 2020 19:32:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id E4F4D6B005C for ; Tue, 8 Sep 2020 19:32:23 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 990F91EF1 for ; Tue, 8 Sep 2020 23:32:23 +0000 (UTC) X-FDA: 77241495366.13.turn07_2305b08270d8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 6C36318140B67 for ; Tue, 8 Sep 2020 23:32:23 +0000 (UTC) X-HE-Tag: turn07_2305b08270d8 X-Filterd-Recvd-Size: 4499 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 23:32:22 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id w186so868530qkd.1 for ; Tue, 08 Sep 2020 16:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=o8jHrcuT+UhHm+x4p55K5Cj+RnXI4w9eRakLutqS70Q=; b=fjSVHbuknhuGPTE8g56tCpaf7IzInC7bCV7CouEraDVgjHPM8nUB8dIS/iH38ZK3xM DBszpcs6gE03JkVE5Fm8RFdEEKqswgNUEQ75tG5V1QoOmFo+boXLEX6xtFTBuQgzdiOr YaxlzXset6AhJ50QnlFDGq4s9+hsDMqyjeGTVCmZtpIgeu0jc11/+Lct/6zj0UMOSvo3 1RXJGwNM3+1D/YgII9Paa2mKaIEbH8F1UWDAl4YycHvPpbgbIyKCfpFLIFeKganR2XNL WJmj5Wl5y9BpW1eotsz9oSKFzMVj3kfBAgTUgJ1qQSjEJmmIyvBU6MVukOa4OciisnuV N30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o8jHrcuT+UhHm+x4p55K5Cj+RnXI4w9eRakLutqS70Q=; b=H4yspqncF3wMRA/TEoQvVsN+JSHBDVDi7vNGm44KAJjGT4xgmDnoZGATNZhO90K8Ob TfAf5ixOj963hy4oySWzmuZf9f+SbuBRbl4O3tYTuqDkw9FwWsIbBceN3QKhoGi5mCyo 1UJ1UZLtI8oaEezn5/+yXpf2APd73cilxiOGoHgSbjxRx6x0q/auOoZrR8VRSZdCTFHP y0/4ScjuwZINJa/UOvG3dsiRLAxiI22ueh1th5yG1i8BDVjEBEqdrzSpPotyeseD3tP1 f5p/LAscxa7d3b/OUOTNmjwsPKV+aGbW3zbpMHRlA9f0k4ibJnlHE0sdjKb1yr/4zD0x UMDA== X-Gm-Message-State: AOAM530raWJprZKsLgLu+FNF1XtSECb1Tp5wGE5Y30PfumEmL0KpgU2X hulo5Tx8PUCycs9V772kfHJXHQ== X-Google-Smtp-Source: ABdhPJyaIuJjWPQ2j+zsck3b5R1hIgcLf9K+Aq2lUdkNJPfgl1QB/eHwhvXDWRRr2hKtT1Tmp68ZNg== X-Received: by 2002:a05:620a:14b0:: with SMTP id x16mr852709qkj.441.1599607942247; Tue, 08 Sep 2020 16:32:22 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id i10sm783768qkh.15.2020.09.08.16.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 16:32:21 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kFn64-0038Dy-MG; Tue, 08 Sep 2020 20:32:20 -0300 Date: Tue, 8 Sep 2020 20:32:20 -0300 From: Jason Gunthorpe To: Mike Rapoport Cc: Mateusz Nosek , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH] mm/mmu_notifier.c: micro-optimization substitute kzalloc with kmalloc Message-ID: <20200908233220.GC87483@ziepe.ca> References: <20200906114321.16493-1-mateusznosek0@gmail.com> <20200906142645.GA1976319@kernel.org> <39c79454-9a97-2c06-3186-939c1f3a2b27@gmail.com> <20200908064245.GE1976319@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200908064245.GE1976319@kernel.org> X-Rspamd-Queue-Id: 6C36318140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Tue, Sep 08, 2020 at 09:42:45AM +0300, Mike Rapoport wrote: > On Sun, Sep 06, 2020 at 06:06:39PM +0200, Mateusz Nosek wrote: > > Hi, > > > > I performed simple benchmarks using custom kernel module with the code > > fragment in question 'copy-pasted' in there in both versions. In case of 1k, > > 10k and 100k iterations the average time for kzalloc version was 5.1 and for > > kmalloc 3.9, for each iterations number. > > The time was measured using 'ktime_get(void)' function and the results given > > here are in ktime_t units. > > The machine I use has 4 core Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz CPU. > > > > The performance increase happens, but as you wrote it is probably not really > > noticeable. > > I don't think that saving a few cylces of memset() in a function that > called only on the initialization path in very particular cases is worth > risking uninitialized variables when somebody will add a new field to > the 'struct mmu_notifier_subscriptions' and will forget to explicitly > set it. Indeed, it is not a common path, it is already very expensive if code is running here (eg it does mm_take_all_locks()). So there is no reason at all to optimize this and risk problems down the road. Jason