Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp747757pxf; Thu, 11 Mar 2021 14:00:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvwIPLKRv1RZJi6naxE6ave3MZMW8Cjb+CcxiqjzRs2tkiHiw5LgtRpdcwUCJeFuciBRNh X-Received: by 2002:a17:907:2075:: with SMTP id qp21mr5321763ejb.451.1615500025433; Thu, 11 Mar 2021 14:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615500025; cv=none; d=google.com; s=arc-20160816; b=dLXqsP/Y6Q8ao+YqieiZ0P7w6ysceLzbrP9A7mPWuXWU+78a0qYsdGjNPyp3TDrNmj dBrFCPi445AV35/1LWay30gLO0uOF6jtKKfhTNcp87dvaD0hrArGWn7jl2byJss/5DWj fA/l8chQ2epTbuwB6JC8xVg6v0edLA5FPhyslrYbbqL6KQr3bd9BI2iHgDJxSNvJ+mk8 XfhWRS66H3jgnAF2bChRpfGW38XGCgXm5hUTqfDiUh3AHs7y7FMR5A46hYlO8SLszx3x kShaZGEVHIi8i/iiLsoN1oyfz/S2TH5emVv2Ial3nNe1EsK7CgxGukHbjyEmff7iqtcw EkAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=dSN6XXkdccaf3+jp0q+rCk4wyWUCe+MlNZeFnrtO3zY=; b=gvrKBEs70mzM9X/U97DfZpI6+w7Lplx11lRqVT/U5A0UQDJx2qgqoF0bzymn1acYIL yAa7GMcdLfuJdKxm9pOJkNtnVqY5Z/59nXMkcCc+l00vektBHhqWWcUp0uBAK1OCCIwi N1xsjnkLo0iBGof4zVCF+5x9TsJ1hO7VgsXqIOrynAKjPaEjZp0IDaoj5aFfccTmP8zM vVd2GEZuRkF4liYEb4+hXP3cpeAbtOvDA7kRzNPyxGhqCixZFnMkw99Lzs6dcaik1JNo /uWfGRP2V+0dHoSF3u6i4S5UAXYVk61R16ZlOybj0l7NNrfAnyHn+GBeDhwxZFGw6gIC Kp0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=qKg7T68C; 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 h19si2462736edb.134.2021.03.11.14.00.02; Thu, 11 Mar 2021 14:00:25 -0800 (PST) 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=@linux-foundation.org header.s=korg header.b=qKg7T68C; 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 S230386AbhCKV5k (ORCPT + 99 others); Thu, 11 Mar 2021 16:57:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:47734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbhCKV5d (ORCPT ); Thu, 11 Mar 2021 16:57:33 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.