Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp658826pxb; Wed, 24 Feb 2021 11:22:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5iCnKNYA/y6OK1eBphF1jOtgoWn2XXGI7aXzPP1QTuDkvHts7MXu3m9GCHcBP7XTUDff2 X-Received: by 2002:a05:6402:1aca:: with SMTP id ba10mr28657980edb.6.1614194541724; Wed, 24 Feb 2021 11:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614194541; cv=none; d=google.com; s=arc-20160816; b=oTpHnTORYX/MWNjJzA1b+nN2ZyJLVlYzw3LZUPA6+jx3aLWAZWEiPRsRlnATF85sqi n76ehKNjBTUroXT046VPTQZLxZ6Y6rhrerzoBF6i8fsEITQm7BIOpJwQFb1iWn6KxuxP XJ4vhF+gZZSJb08m/0vvlwF53m3RUaJvYDFKEeonbpXgfZJr+kynLj3+zISLtGJ3F91B Gowh1OFI6lDkpe6s887xZH9Q74SEnRTH0ROnhTXyhV7EoLk1mxdZbR4BaSbxVZ4fMz6Q E5ArxdLnK+pLYR7bqWUaiVnZ1tVjEs3se+h3ZOY3gT+0H6MdaBdyvEqN6fSf1LS5azLW Ahbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LsetPJB5m47FCg13KC6GjSTLKBsPDI7MuzXhPKMTnS4=; b=DXSKFIsqCgda3fnWz1pZL9RqSft5sTJHCjoO20W43KnA5dJi541Fe1K9d5jk8UPlrR zYYBe8frpoV77zhmsjoURvyRdXm+TRQMiHaRxetKUfOdIFynf/bQ9uSRMpjPtBY+p3RK oXi9/0aq0mrvVyDprKsMF6/dt9aPjVuLeogGvWjhAfocuL1yhptaOWx+K0M6yqxgczbP lnSI8iOXhYvjtzmGfKq99QcfFpxNSF5aIVeMcg+e4EXckFmOwBP8hi5ygY/J9rhQPTWw ZKLdd2pUueubtGuCqq76u6b6rHaBhFk0algSwKcaX5/Q0xxg3Be85XCug6s51iZA+XT5 5kTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=g0wCVRLu; 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 a6si1736410edu.356.2021.02.24.11.21.57; Wed, 24 Feb 2021 11:22:21 -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=google header.b=g0wCVRLu; 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 S232290AbhBXTT0 (ORCPT + 99 others); Wed, 24 Feb 2021 14:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236139AbhBXTTR (ORCPT ); Wed, 24 Feb 2021 14:19:17 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EE38C061574 for ; Wed, 24 Feb 2021 11:18:37 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id w36so4758794lfu.4 for ; Wed, 24 Feb 2021 11:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LsetPJB5m47FCg13KC6GjSTLKBsPDI7MuzXhPKMTnS4=; b=g0wCVRLuZhRAZSx2tZaeQKkHmjHJt6HcVeX1wF81XK3ID/P21CzwT5FyHF6bzyJiaK 7Wbpg65iES9Lwj24IG8yT/fkKOgtfPxfvdKC+qXihnsfhzxP5qlnVz0sgNHOO9KXWCV6 eIoO/wnpUtMRNAs14sprZgujgxrvqBNk1ASSY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LsetPJB5m47FCg13KC6GjSTLKBsPDI7MuzXhPKMTnS4=; b=tr+ieX7K9ikVuAzad0r/4Lvec/TuNvshWpoR1cw4mZYJ5jfmenVoZYHPIZmQevESYF A4jhIrrlTUday2OWiJv6P34NKdGdAcIZuEbm4kEhjwuVcoHlO3p8rXLUCpKCnewc0y9P WbgPcx1I60ncRKWks142pBJXDXtALsrOFRKeJhqPrFUHjc0GIEZnHFBK+eJcnccrYhkh h5B+NYOrOk1Nse1Arv+eTF9WKl3Gs2heBn/G8QXtIgDzFYTIQxoi9vMGE3kpZsP7NS9N DCgtMbCmlArhLL7s7LWehNdDg8OPjGzqXr8OiqBvgQK1pC9sqiQWU0EtcO0fUC0fNKLO yLTQ== X-Gm-Message-State: AOAM531pIo72+ilbsqcGDCxUhVEncwnZPOvu3L0yuPN3FoqlRhKhcBgR FabCDIEzuyiJSQLwvU4Gw99mrR/C7No/Gg== X-Received: by 2002:a05:6512:31c1:: with SMTP id j1mr21033408lfe.313.1614194315379; Wed, 24 Feb 2021 11:18:35 -0800 (PST) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com. [209.85.167.45]) by smtp.gmail.com with ESMTPSA id h28sm650452lfg.234.2021.02.24.11.18.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Feb 2021 11:18:35 -0800 (PST) Received: by mail-lf1-f45.google.com with SMTP id f1so4783121lfu.3 for ; Wed, 24 Feb 2021 11:18:34 -0800 (PST) X-Received: by 2002:a05:6512:a8c:: with SMTP id m12mr20000602lfu.253.1614193859813; Wed, 24 Feb 2021 11:10:59 -0800 (PST) MIME-Version: 1.0 References: <20210224051845.GB6114@xsang-OptiPlex-9020> <20210224183828.j6uut6sholeo2fzh@example.org> In-Reply-To: <20210224183828.j6uut6sholeo2fzh@example.org> From: Linus Torvalds Date: Wed, 24 Feb 2021 11:10:43 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: d28296d248: stress-ng.sigsegv.ops_per_sec -82.7% regression To: Alexey Gladkov Cc: "Eric W. Biederman" , kernel test robot , 0day robot , LKML , lkp@lists.01.org, "Huang, Ying" , Feng Tang , zhengjun.xing@intel.com, io-uring , Kernel Hardening , Linux Containers , Linux-MM , Andrew Morton , Christian Brauner , Jann Horn , Jens Axboe , Kees Cook , Oleg Nesterov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 24, 2021 at 10:38 AM Alexey Gladkov wrote: > > One of the reasons for this is that I rolled back the patch that changed > the ucounts.count type to atomic_t. Now get_ucounts() is forced to use a > spin_lock to increase the reference count. Yeah, that definitely should be an atomic type, since the extended use of ucounts clearly puts way too much pressure on that ucount lock. I remember complaining about one version of that patch, but my complaint wasabout it changing semantics of the saturation logic (and I think it was also wrong because it still kept the spinlock for get_ucounts(), so it didn't even take advantage of the atomic refcount). Side note: I don't think a refcount_t" is necessarily the right thing to do, since the ucount reference counter does its own saturation logic, and the refcount_t version is imho not great. So it probably just needs to use an atomic_t, and do the saturation thing manually. Side note: look at try_get_page(). That one actually does refcounting with overflow protection better than refcount_t, in my opinion. But I am obviously biased, since I wrote it ;) See commits 88b1a17dfc3e mm: add 'try_get_page()' helper function f958d7b528b1 mm: make page ref count overflow check tighter and more explicit with that "page->_recount" being just a regular atomic_t. Linus