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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 02C4EC433E0 for ; Thu, 11 Mar 2021 21:57:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C17B64F64 for ; Thu, 11 Mar 2021 21:57:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C17B64F64 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A21D28D0307; Thu, 11 Mar 2021 16:57:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D1338D02B2; Thu, 11 Mar 2021 16:57:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84D978D0307; Thu, 11 Mar 2021 16:57:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 65AC38D02B2 for ; Thu, 11 Mar 2021 16:57:35 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2013F613B for ; Thu, 11 Mar 2021 21:57:35 +0000 (UTC) X-FDA: 77908955670.22.790FDE9 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP id 6CE544080F46 for ; Thu, 11 Mar 2021 21:57:25 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id D7B4164F6E; Thu, 11 Mar 2021 21:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1615499853; bh=rC15oV0fbK8A5ObAa2CpTtMWW4MIKdxs15W9uBiS6+Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qKg7T68CNkgdxXLkqz8b9eqMlWGpFqhgcyixcu6qS43Ytn4rWikpLMgOd+beraSFB DR+a+S1d53ajyOvIkieO0EL53FqTQrozxlAIoIFReEwkgO0wkta1ywB8zV5Xr7/PYf hapTvx5P8ljpTzt9J3bcHSU3DHZaeEAUw/LH2ooE= Date: Thu, 11 Mar 2021 13:57:31 -0800 From: Andrew Morton To: Yejune Deng Cc: walken@google.com, hannes@cmpxchg.org, louhongxiang@huawei.com, linmiaohe@huawei.com, shakeelb@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm/rmap: convert anon_vma.refcount from atomic_t to refcount_t Message-Id: <20210311135731.b0ce4c346aa8ade64fb9b5fc@linux-foundation.org> In-Reply-To: <20210311055615.4461-1-yejune.deng@gmail.com> References: <20210311055615.4461-1-yejune.deng@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: qm9i8nectnd3mpb1axtt4d5rojf58595 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6CE544080F46 Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615499845-853127 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 Thu, 11 Mar 2021 13:56:15 +0800 Yejune Deng wrote: > refcount_t type should be used instead of atomic_t when the variable > is used as a reference counter. This is because the implementation of > refcount_t can prevent overflows and detect possible use-after-free. The use of refcount_t comes at a cost: q:/usr/src/25> size mm/rmap.o text data bss dec hex filename 31114 2147 32 33293 820d mm/rmap.o 31558 2147 32 33737 83c9 mm/rmap.o That's a bunch more instructions to execute on some fairly hot code paths. I guess the debugging/checking features are nice, but this is pretty mature code. I'm quite unsure that this tradeoff is a favorable one.