Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4299831pxk; Tue, 8 Sep 2020 16:36:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws+wV2ihmjg46+2pvHROg0zYY9c8XNvpXyiSLujWMudvA1g8bBoLg0HjSvIupgHl58g1RD X-Received: by 2002:a17:906:300b:: with SMTP id 11mr900068ejz.270.1599608177963; Tue, 08 Sep 2020 16:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599608177; cv=none; d=google.com; s=arc-20160816; b=VYS2GPouhuj6BM/PVIxuDzHM4vZcpgrluNWftPrrD7+w+6lIaNrBxlKfBUhXdd1qYA TpmP8YyMOe4AYDlFg5LrirtyEWsoKXH1GscdyILQVeEfVYpE6wVt+4Dus0Jl3ixQ7uFw zZsMpuMGgsVhhpUl2fXutPsqJ70LdmJM+dr00Ogvu9EjG4CXmo3nHupoLF7zkZQQOG8o oRFn1yOMULdtYMKCum9Ghn6MsVjPh4xjcW06yysHvNF8FgfNgPdYVRuU0eJaSyRLtBza KXAv5neER1gCxtStv2O9xZf4MxhGpiY0E1JCVJ/OE0SMuzZoPZQo76irAGd7Q4CyPNh8 GSOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=o8jHrcuT+UhHm+x4p55K5Cj+RnXI4w9eRakLutqS70Q=; b=NOC6tezRDqeM+N6c62AIvxUmtDy7m4gFQKWhQCS96/fZnYsZPXMl6uqIePKxTqrHEE zvyQKkXzid3VLGM/Bs0kH1bgA4cLMyBKlwH6maIgLTBJzMOZAzSeYfAH625+RgX4q+V4 bG3tc5/pNyA0OnsPu+mJi5MIXsJXwD80lXXVIcdzyFC/9U+TJdpmerAYU6FlQc1ccKiI cqP3ZwRRqzJuevReed5f3/U4XsiPmwhEMKkTOcAp3DAHKAm/b9T2fs6IlsQf//1U0HET 6K1Nqusn2s4PWNKpZflZBqK6xVcP42cK1RrfPb/OhxdoClIwNmzMgVl52w6hL+g48DyB ebHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=fjSVHbuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si305580ejp.78.2020.09.08.16.35.48; Tue, 08 Sep 2020 16:36:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=fjSVHbuk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729212AbgIHXcd (ORCPT + 99 others); Tue, 8 Sep 2020 19:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbgIHXcX (ORCPT ); Tue, 8 Sep 2020 19:32:23 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C12C061573 for ; Tue, 8 Sep 2020 16:32:23 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id o5so797059qke.12 for ; Tue, 08 Sep 2020 16:32:23 -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=kP/cTL61lc3esoSkqccsjXtf6J1yaQDxwf/Mv4TF3ly/ljO6t/7P2xzjf5BtVo5bAk hIulj40S8EsxC4kwBBtVkulKbrD3OpR9fOnmc9nLylm7CG0ZTsfyMVc/TH7NjxSGStEb 9RHzfUVVgavBrkIU8tPxuhptGDQFW2wO660Rns8rcV89ICr+kLqoPHIo15rCQ5oeC807 iVsX5hNW0/2v+vDr5fG7LqYv+Qoc57yRo2xqMsviLmSEZNft5YLK/hX9nOo7gSf/fo56 MeJhxkXji+eL2Xzj2QDDL7hX4EPPM7oYrG4DtfQZjaKcJsxqt3fhcJbaakPDtNY8jP+x 05eQ== X-Gm-Message-State: AOAM530wf0mWRx+/7M3E6dXmYVDcfXCCrWXhkeW2ZA43hAejydLTrRWc oo0Dim32P8oshZOKk6a/Rwf1Hw== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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