Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1916997pxb; Fri, 27 Aug 2021 22:30:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYGwd8rb3zcFaoaZVLpyR5VgqYLXP/cNXjfNUUgxO+YWCxs5Z54i4nSRA0e57uHcdEnlYx X-Received: by 2002:a17:907:10cc:: with SMTP id rv12mr13575594ejb.423.1630128645298; Fri, 27 Aug 2021 22:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630128645; cv=none; d=google.com; s=arc-20160816; b=tT8XbwfD4cDq0XmtyiGcS/BZTheE3j6Qu/XG5iZbVZQfrkR5mQZzAEZVvBT9pRIT49 /akxoOfHYUXVT1pcmJ88Lio9eedxUwnlgzSqVAv6LJf4nUzV0ZzrjYJt2TKJM7TDRFwR eJQFWm6aYraf0fnQdirQ3CV6RJco8/2iuGdoT0CLobvUJr4OFrA9jNSgjK27P2Ao+bII YLz6hlEBJe+WlHvOB/fMf4WT9bdJSMEeSfrV3DHOvAljg6uUbfdMSfEfVYtiUUex7xLA A+dAzhoBvsk2xdU1PPIw60CwehAQIoJmKWWCc4dxvONZ6otARYtaX679WcWFOrRq/fon hhlA== 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:dkim-signature; bh=stWDJ7pxROB/EYFBbI7ThyH/rSYnoU9WnqG7bRnPt18=; b=hPoNAAxjGVwilsJELjNeo5m2sEB0k4NbW/sHoTbOWzRZZbu5EIKw0kyTxPDPLYoCIo UE9o18jhTyNQPp/K+zuOsMf8X88hYwWMe2ZRXeLGguQDT7rMw+Ena+2ZntNPnkzBDXyG Xey2R1Uku39Z6PJKRZyUIJ6pcCRpEVHeEc4FSfk3tQeJaL/V2hGu9Jpyx2iHr8hiB99H BOEykESKR6gS038G7M5i82LZr6j2Fti4Aa3+FJq83YBAoJe3NxNebOpXzzpMciOPMa1D 66hfXLV8+u21snHZDzwuZbdocn3Uy9OxavEzjZvLJ3Ptth4XYWMstV9wnnneXs1nhgTf yvnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bt25+nM3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si9163224eds.407.2021.08.27.22.30.16; Fri, 27 Aug 2021 22:30:45 -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=@chromium.org header.s=google header.b=bt25+nM3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbhH1F3g (ORCPT + 99 others); Sat, 28 Aug 2021 01:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhH1F3e (ORCPT ); Sat, 28 Aug 2021 01:29:34 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FFE3C06179A for ; Fri, 27 Aug 2021 22:28:45 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id x16so7575044pfh.2 for ; Fri, 27 Aug 2021 22:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=stWDJ7pxROB/EYFBbI7ThyH/rSYnoU9WnqG7bRnPt18=; b=bt25+nM3eSC/BvfoTicc0kvU8X0ALlSypYs6nMG+ihBxWlZaCFTdELOgHd4ypV3SQF bNmfO7MJWL23KdE8b6R633QbGHj6wsYkr8qI4bQIAjy/oem5n+xTmj1AvXlQVcFUHF+r KxLKNJshPsF238Mfaa8vML8FvFyRRVbeIlieg= 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=stWDJ7pxROB/EYFBbI7ThyH/rSYnoU9WnqG7bRnPt18=; b=X9WSIkOcM5koO8kbvZAKyn0Zp7piQxR7W+bQ+LV5uBPg5WufpReXoAVAubzsMMZRF3 nG2TQpgwfh7t0EZjPovBLqI80yWtsxq7I5RdWIB7E8HARUdkKgWQ3DWqUsSlW6CiGHt/ Qd7GjHsPTIlO406Eg3Xq2gqSm6aGEQUEjfCrPmkBJMOucSyk5Gjl328OunzxhWhSN7fn hWOCdW5/CWxpHvrsoetUmi48O/qexuckRIM3ENqqEwptVC5vS8TQdgfP3f/iF0naETKr HLzbVtX3pZ9UPPS4zCgvhbZnm+dJVZxlQKow5l0Ctmzfx6S9aQEpap8YdecULXtAxTzW 0KAw== X-Gm-Message-State: AOAM533LXaXO6gfJ4JEjOXaf4VAnusYK7r45Tt9dyudynqztK6yquoqI gT70Uo7LqcNJfLSeTkr6gRlcDA== X-Received: by 2002:a05:6a00:2142:b029:3b9:e5df:77ab with SMTP id o2-20020a056a002142b02903b9e5df77abmr12703170pfk.52.1630128524423; Fri, 27 Aug 2021 22:28:44 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d18sm8883397pgk.24.2021.08.27.22.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 22:28:43 -0700 (PDT) Date: Fri, 27 Aug 2021 22:28:41 -0700 From: Kees Cook To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, ccross@google.com, sumit.semwal@linaro.org, mhocko@suse.com, dave.hansen@intel.com, willy@infradead.org, kirill.shutemov@linux.intel.com, vbabka@suse.cz, hannes@cmpxchg.org, corbet@lwn.net, viro@zeniv.linux.org.uk, rdunlap@infradead.org, kaleshsingh@google.com, peterx@redhat.com, rppt@kernel.org, peterz@infradead.org, catalin.marinas@arm.com, vincenzo.frascino@arm.com, chinwen.chang@mediatek.com, axelrasmussen@google.com, aarcange@redhat.com, jannh@google.com, apopple@nvidia.com, jhubbard@nvidia.com, yuzhao@google.com, will@kernel.org, fenghua.yu@intel.com, thunder.leizhen@huawei.com, hughd@google.com, feng.tang@intel.com, jgg@ziepe.ca, guro@fb.com, tglx@linutronix.de, krisman@collabora.com, chris.hyser@oracle.com, pcc@google.com, ebiederm@xmission.com, axboe@kernel.dk, legion@kernel.org, eb@emlix.com, songmuchun@bytedance.com, viresh.kumar@linaro.org, thomascedeno@google.com, sashal@kernel.org, cxfcosmos@gmail.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com Subject: Re: [PATCH v8 3/3] mm: add anonymous vma name refcounting Message-ID: <202108271746.F444DA6C9@keescook> References: <20210827191858.2037087-1-surenb@google.com> <20210827191858.2037087-4-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210827191858.2037087-4-surenb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 12:18:58PM -0700, Suren Baghdasaryan wrote: > While forking a process with high number (64K) of named anonymous vmas the > overhead caused by strdup() is noticeable. Experiments with ARM64 Android > device show up to 40% performance regression when forking a process with > 64k unpopulated anonymous vmas using the max name lengths vs the same > process with the same number of anonymous vmas having no name. > Introduce anon_vma_name refcounted structure to avoid the overhead of > copying vma names during fork() and when splitting named anonymous vmas. > When a vma is duplicated, instead of copying the name we increment the > refcount of this structure. Multiple vmas can point to the same > anon_vma_name as long as they increment the refcount. The name member of > anon_vma_name structure is assigned at structure allocation time and is > never changed. If vma name changes then the refcount of the original > structure is dropped, a new anon_vma_name structure is allocated > to hold the new name and the vma pointer is updated to point to the new > structure. > With this approach the fork() performance regressions is reduced 3-4x > times and with usecases using more reasonable number of VMAs (a few > thousand) the regressions is not measurable. I like the refcounting; thank you! Since patch2 adds a lot of things that are changed by patch3; maybe combine them? -- Kees Cook