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=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 ED01CC43461 for ; Sun, 6 Sep 2020 11:44:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 54C6620C09 for ; Sun, 6 Sep 2020 11:44:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nFL9f+Ru" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54C6620C09 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6FC876B0002; Sun, 6 Sep 2020 07:44:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ADC96B0037; Sun, 6 Sep 2020 07:44:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C2F36B0055; Sun, 6 Sep 2020 07:44:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 43D486B0002 for ; Sun, 6 Sep 2020 07:44:22 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E56F21E19 for ; Sun, 6 Sep 2020 11:44:21 +0000 (UTC) X-FDA: 77232453522.02.ear72_4408974270c3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id BA9DF10097A20 for ; Sun, 6 Sep 2020 11:44:21 +0000 (UTC) X-HE-Tag: ear72_4408974270c3 X-Filterd-Recvd-Size: 4126 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Sun, 6 Sep 2020 11:44:21 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id a22so6467303ljp.13 for ; Sun, 06 Sep 2020 04:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wwpbl2l3OHrzIL91Ex4axf5Culwn884/sH5r7StvL0I=; b=nFL9f+Ruq/nE1q0Cyj/r8lJyGOgs2H/s8ksZhHmMRgPwU5UFX2B67dJLzwB8AHIC9Q ecrb+uUTObtLluKc/ut1fpVcv4Y5p9RnglpeGi82nG+3BBD5w17ZXu9cqrnWVaKhrxEX dX4qdTHhadLuocRg6FteHp8+FLf1m/2hKEL2m8naIq3+srH5eTveS0OZC1jzn0FFJrMl NVD40V1QakAubQ94WG1DIVUm7+N6HC76w0Nr7pZtudTV5XAMVsoX29OMXlRsK9DmIuwQ g2KWGoC0WvEkx3d/FtcFkGhGW0zLGNQXtJ8Qgauxr/YRU9dwUMlfa0MuL8Q9DSXeeGAd nCVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wwpbl2l3OHrzIL91Ex4axf5Culwn884/sH5r7StvL0I=; b=nFXvNnOnpczMTNr5hTxQ+aYH56aTw99gQ7iOOry9Eifq7kehRpQope+DVQZcYaTZHt Tv35qoNJCfYoLUqyNzn7uVFJUYcH58M4g+XBodWYOJNqoHbuPWb6li2DeOJEpbM6UrhW 1n2586DZndAkcWMjZeGhzhYDy894mUsaJiM/rRmZBrU23epEQ3DQpcDHZ1cdXWcMPURj SVp3DRSCiCU+QP3ucNjkc4sHlL4vvh9c2/nsCjZcYWr5myZ7ZxpKBMnNSm4xokrdAkq2 iE9+pw8ynRS7BFGBbV8GdOR/HrpqVb5uybu+BW2BIKj0OdDHnWOJrAkFpB0MjJWVPOjr Y3DQ== X-Gm-Message-State: AOAM533DJPJoPb46h7AfbEZTzZ3Xf1Qr9hMTFjnkXPurPMurmcwVweH5 u4lVFacPTO6QD1O1FsdaLIUlikMKgP4= X-Google-Smtp-Source: ABdhPJxcRambJVutqGscXflSXaM1rGPnz8BaIaQn1d5QOcqcn/CNom+aDwOvTrdCg0requTVsLG/FQ== X-Received: by 2002:a2e:920f:: with SMTP id k15mr8201163ljg.353.1599392659471; Sun, 06 Sep 2020 04:44:19 -0700 (PDT) Received: from localhost.localdomain (188.147.111.252.nat.umts.dynamic.t-mobile.pl. [188.147.111.252]) by smtp.gmail.com with ESMTPSA id l14sm1452779lji.99.2020.09.06.04.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 04:44:18 -0700 (PDT) From: mateusznosek0@gmail.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mateusz Nosek , akpm@linux-foundation.org Subject: [PATCH] mm/mmu_notifier.c: micro-optimization substitute kzalloc with kmalloc Date: Sun, 6 Sep 2020 13:43:21 +0200 Message-Id: <20200906114321.16493-1-mateusznosek0@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: BA9DF10097A20 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000156, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Mateusz Nosek Most fields in struct pointed by 'subscriptions' are initialized explicit= ly after the allocation. By changing kzalloc to kmalloc the call to memset is avoided. As the only new code consists of 2 simple memory accesses, the performance is increased. Signed-off-by: Mateusz Nosek --- mm/mmu_notifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 4fc918163dd3..190e198dc5be 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -625,7 +625,7 @@ int __mmu_notifier_register(struct mmu_notifier *subs= cription, * know that mm->notifier_subscriptions can't change while we * hold the write side of the mmap_lock. */ - subscriptions =3D kzalloc( + subscriptions =3D kmalloc( sizeof(struct mmu_notifier_subscriptions), GFP_KERNEL); if (!subscriptions) return -ENOMEM; @@ -636,6 +636,8 @@ int __mmu_notifier_register(struct mmu_notifier *subs= cription, subscriptions->itree =3D RB_ROOT_CACHED; init_waitqueue_head(&subscriptions->wq); INIT_HLIST_HEAD(&subscriptions->deferred_list); + subscriptions->active_invalidate_ranges =3D 0; + subscriptions->has_itree =3D false; } =20 ret =3D mm_take_all_locks(mm); --=20 2.20.1