Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1258049pxb; Fri, 20 Aug 2021 01:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS+Gyga8ghCWtYYnuNVBxSddmVG+Dzjy3JSlgCrT3kvPNhKgWaSZFGZs3umpNoemobpIAx X-Received: by 2002:a6b:fc1a:: with SMTP id r26mr14926398ioh.30.1629447717658; Fri, 20 Aug 2021 01:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629447717; cv=none; d=google.com; s=arc-20160816; b=Z2CVuVZBvrd3lUEuWe73VpAcylMuB+TvL2mEKBH76dUcRohe53tiJMhwx21mClr/TS y5Jmq6sK+mxk0vXFd6g/GGyGbz/wHruqtseeW43Z+eh9QM6K6GzQdTK19ccoEHE9ijNB wH5elCqFPlc1gYe8WSR0M1TO0/XY9HkhSOLX0Td5bGEGiSGUPrZURgg5nQ4J2XGRyCr8 HDt4w2Eo7Yvj/2746vrvrjv798CSJnvk1CL7O4zJlMuJ4pUF6lNDJEIuUE1qJLG2rqK2 GEoPxFe7jSGQXuVuyqVmm54Ce72RKH3ZR23gZZk6VsZslRl7VGjvRXiWG7FfMxcjeYCk m3Tg== 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=YFi+FW2U2s7s29whrwZAMBkRsLUDaIoWOOpz9VPBCJc=; b=lemGA9MWk/ZFpfUGpO2KJGOL6O+WoIPPl0ntcgwPyqzccELswlJaH8X99eVeFaGPez jTyh3tzHnb0bdFQCOSygBjUc5ydrFg4sVcFHo+b1z4KNHv0h0WpHKJsUXi7ERJIRmsBz iU7xKMUmYl98NChREypkllTRKU9iLCOivzfVgq69rKb/QN4tF8UZH6qa65wVF/xDfF65 DlQmvyHec1bhI2nRv1nORtX2ueoNoWeOdyMEJgde+92tU/b2OkT23n8UYpa7MDx87SFJ rGUvzY2BfR0chT+xdLGQy32uwhRLBIvS+DQyWxlFVOUaAaRHWe0wjYx+Nb4Ys2LKAyqN tK0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RJ52XRy7; 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 c6si2333536iow.84.2021.08.20.01.21.46; Fri, 20 Aug 2021 01:21:57 -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=@infradead.org header.s=casper.20170209 header.b=RJ52XRy7; 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 S232029AbhHTIUq (ORCPT + 99 others); Fri, 20 Aug 2021 04:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbhHTIUp (ORCPT ); Fri, 20 Aug 2021 04:20:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48249C061575 for ; Fri, 20 Aug 2021 01:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YFi+FW2U2s7s29whrwZAMBkRsLUDaIoWOOpz9VPBCJc=; b=RJ52XRy7Mbgn6kkEQRDJI1GNqh 2icOetgEGmJ9/zuyZrXd3JV4fhXN+gFZh+vNyyDo+2kMmkm3Pljp9OFFdEZnWRi20ll7ZmVLWxp7n XmlFl/hD0cRYEemaQNV9j/pEuqCfgnkztOm3IhVLj+lwy4WWpIeEYdL6f7JovuEA9EHSEFfwEsyA9 tCsEMpdbDmD37Jm1ow5sptIvB/6zpFx17QcqdIHnBSYlfR71VJfD1IRw8ELTI+y5IOtAxtNNJ9Rwg sq4TnhZ3MSCspgatiu6/19kn90GVqO9x6Q6ErDxNRTwa4A+fdpUns5b6VeIppLZU4XHG6gnX5e0M4 Ox8Z5+Wg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGzhN-006Ew6-JE; Fri, 20 Aug 2021 08:16:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 1EA5B3004B2; Fri, 20 Aug 2021 10:16:19 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id F2F802D80FBBE; Fri, 20 Aug 2021 10:16:18 +0200 (CEST) Date: Fri, 20 Aug 2021 10:16:18 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Will Deacon , Andrew Morton , Borislav Petkov , Xiyu Yang , Alistair Popple , Yang Shi , Shakeel Butt , Hugh Dickins , Miaohe Lin , Linux Kernel Mailing List , Linux-MM , yuanxzhang@fudan.edu.cn, Xin Tan , Will Deacon , David Howells , keescook@chromium.org Subject: Re: [PATCH] mm/rmap: Convert from atomic_t to refcount_t on anon_vma->refcount Message-ID: References: <1626665029-49104-1-git-send-email-xiyuyang19@fudan.edu.cn> <20210720160127.ac5e76d1e03a374b46f25077@linux-foundation.org> <20210819132131.GA15779@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 20, 2021 at 08:43:40AM +0200, Peter Zijlstra wrote: > Fine with me; although the immediate complaint from Andrew was about > size, hence my UD1 hackery. > > > So if we do this, I think it should be something like > > > > static inline __must_check bool refcount_dec_and_test(refcount_t *r) > > { > > asm_volatile_goto (LOCK_PREFIX "decl %[var]\n\t" > > "jz %l[cc_zero]\n\t" > > "jl %l[cc_error]" > > : : [var] "m" (r->refs.counter) > > : "memory" : cc_zero, cc_error); > > > > return false; > > > > cc_zero: > > return true; > > cc_error: > > refcount_warn_saturate(r, REFCOUNT_SUB_UAF); > > return false; > > } > > > > and we can discuss whether we could improve on the > > refcount_warn_saturate() separately. > > I can do the refcount_warn_saturate() change separately. > > Let me go check how small I can get it... gcc-10.2.1, x86_64-defconfig kernel/event/core.o-inline-ud1: 96454 kernel/event/core.o-outofline-ud1: 96604 kernel/event/core.o-outofline-call: 97072 (42 refcount_warn_saturate/ud1 instances in that file, 10 of which are refcount_dec_and_test)