Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1065658pxb; Wed, 27 Oct 2021 18:38:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWYXgPk2MhdOFpcGQEMZwna7ed+htO/+5m47R5yQ+EC2UZgMvdf1xt8darSq9/VkBJGJpX X-Received: by 2002:a17:907:160b:: with SMTP id hb11mr1498547ejc.492.1635385098507; Wed, 27 Oct 2021 18:38:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635385098; cv=pass; d=google.com; s=arc-20160816; b=nzfyns0Aick7KcvJWvndtk1t74TYxVx9chknR5teY9MEj/xAk8XH54eOa3viz0vjMo Z36xeHRnJUWh1z7KKEx9YAaiX9DRXioO5R8Fd7kb4VcR09SGQ60U7YmKzPxPf28OFfFr dHCIKumuXKp33LysQIGmTQv/b1ESkv0jc96qvCGib+5KJyaMmP6gNxBcs1hI5UwqTA4D oyKzjld7WnaTSg6Q2GnIByul/vZ0lMUF3ofIU7FqX2Ls+kd6O8VB0SNa7yDmJ9MRIpwX Zj0KD3ukZlKlTEVSWhVjuXnHw8zJRKQjsKbAoByQK/SVAh93YXe5tD2W5Oxkz12Wzqs3 mOPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:references:cc:to:from:content-language:subject :user-agent:date:message-id:dkim-signature; bh=M9+CRJoGAS5aw7CIQG4gBxEpV9giODhqPR45bMJNhyk=; b=ZWVcojATPPPNWmlnIg/i1QD5ANPfnQVCE9VoEQRLeOvHs2xKKP+yWODe5fCgZ7cBJC Gy0Q5N76LwEbLUndvaK93N5zMRMcnU7/ForPms6ssR6YCUVv9+ZPLgI1UcaGugJSc4rj 5dVCVyViXBrpCYu+j2BrxahEFrMnhAMDAVLRwZxqHmP4hZoxA8MHs6Uxh4+in7ko27eq A1uFYwUK8vjo3etp2YE7iSd/WIhHW2bgc5SJiR6+pd6QJR+ee6rbha3jlYnYzlUxH1Ct NX3o0wrVDgrmSAKg+HSyK+7LHabLgbXsklvev73yMHzeesDL1DPqBuSH9WFB/YfxgtFD GDMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=cXGanOn3; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hc20si1993500ejc.620.2021.10.27.18.37.54; Wed, 27 Oct 2021 18:38:18 -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=@Nvidia.com header.s=selector2 header.b=cXGanOn3; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbhJ1BiW (ORCPT + 99 others); Wed, 27 Oct 2021 21:38:22 -0400 Received: from mail-bn7nam10on2047.outbound.protection.outlook.com ([40.107.92.47]:39979 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229534AbhJ1BiV (ORCPT ); Wed, 27 Oct 2021 21:38:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aoqOuTx3Y8Fw0/b1LdfG/5wVqHYFGHnQNeBUPgT+n9czWs0wcImauiY3xLsnvfS5K0/71Y22/+VyFfvWhOm+A2VIJ3T9KtWM7gDg9cIU1RokCv4SWTLu4TaffIA9cfXPDOjsQCSdOK5WxKYGe/P2Zd6LO5fthvLY4W/MbcZMvjI722O7Cv9g0225NrPtCCvc9n4NPMoZFeX8TKDtKlqbr/tSMZK6yHCSToH/2cKZo+pKy7tNqvJJh+CFo3KgOY+jR20Jms44ooenDQLRq0RoEU4raoCT5fblWw/Oa0v6EslFbJitKqvQRi2HL2Du89YYwMZLYMKmopV6E5WOuVn4tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M9+CRJoGAS5aw7CIQG4gBxEpV9giODhqPR45bMJNhyk=; b=Rro9dQ24AMBzXdJZArP2B9tI94Iyeai1INutKtRI63ENeGUQYZElQcVuLGO2R/ncuNkJVKcLhFTR8x5m6S4Lytfw7CyNWsTlzAv1BMu5v0h/4g89j6H1aGMPG9vuwFI+qDNw//pVtBVrHZPmwuURYyNMS9dOZ61iYVXwB0rOK7llOcxGqAy5ZTIW/qoqh3HN41oR82uKBKMcZ8+1xTGHihZ+1r48fR/0IpTNSoPdNrPyF67B/idE8EaAJAP7VqYXpuOc5PVxPOMGDtEJc5IeUn1Jz1qgPupyB9Nld7549ktn444EHjlRY1gVGEQAVr54XjkQdDK5kkIhx189M0h7dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M9+CRJoGAS5aw7CIQG4gBxEpV9giODhqPR45bMJNhyk=; b=cXGanOn3x+dQute9LHjRJyi0V5tfIujhJqExeCMpckkpyTfXGVsuB8VlZstXoR454xkrwhXWjtohH4MF3NkorGRnpHE5WkMpKjqohdJ3F8FX7HfA77DXRKgL1ia5AXdLQ3fzfy6aWq27U0isQHsVJzIsY1c2TZ0UKZsbA8WkNMpNYV8KV/uLgdOmvN9Y6nsgYoy63Bsjy7uJb6gfnS2Ldl26bcGLxiCCdAO+8a+zejJRKdvBs4xpEN2e6zEyDde1aoszGcaQE4pPJ5kJ5cVVix+43jvbfCi4C8HAhYWwRuALNf3qB4vMN8PDA7+05ldLBWwF8yklA1chWEC5r8ngIw== Authentication-Results: soleen.com; dkim=none (message not signed) header.d=none;soleen.com; dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by BYAPR12MB3464.namprd12.prod.outlook.com (2603:10b6:a03:d9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 01:35:46 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::a0ac:922f:1e42:f310]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::a0ac:922f:1e42:f310%4]) with mapi id 15.20.4649.014; Thu, 28 Oct 2021 01:35:46 +0000 Message-ID: <27b7177c-71be-9ff2-716e-caaa5035d451@nvidia.com> Date: Wed, 27 Oct 2021 18:35:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [RFC 3/8] mm: Avoid using set_page_count() in set_page_recounted() Content-Language: en-US From: John Hubbard To: Pasha Tatashin Cc: LKML , linux-mm , linux-m68k@lists.linux-m68k.org, Anshuman Khandual , Matthew Wilcox , Andrew Morton , william.kucharski@oracle.com, Mike Kravetz , Vlastimil Babka , Geert Uytterhoeven , schmitzmic@gmail.com, Steven Rostedt , Ingo Molnar , Johannes Weiner , Roman Gushchin , Muchun Song , weixugc@google.com, Greg Thelen References: <20211026173822.502506-1-pasha.tatashin@soleen.com> <20211026173822.502506-4-pasha.tatashin@soleen.com> <7b131cb1-68d8-6746-f9c1-2b01d4838869@nvidia.com> <19d16b40-355f-3f79-dcba-e1d8d2216d33@nvidia.com> In-Reply-To: <19d16b40-355f-3f79-dcba-e1d8d2216d33@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BYAPR07CA0067.namprd07.prod.outlook.com (2603:10b6:a03:60::44) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 Received: from [10.2.57.12] (216.228.112.21) by BYAPR07CA0067.namprd07.prod.outlook.com (2603:10b6:a03:60::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 01:35:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e49d38ea-0ff1-4ee6-5632-08d999b3435f X-MS-TrafficTypeDiagnostic: BYAPR12MB3464: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BOu2girlRJ7q8LM3y68zyBtT9SDEtPafiGP8IcX7pLm7kp9XAf+A3RWR3Ne0lnsyPCIte3vz0TjbxKfgtE4Kuy65QoL0pxsK2cnY6nQpQAEWhVG/3APoOQVsQX2llhiUQEm03xIJhVbKnL/PqIO3VUU/hJtPZwelhx5plQR6P8xwmLxkDtoJPQsP1ARVJ6PkFmqjGR2laxsGt1Zcq03Wqw7WhjzaTLlgx9Z28djs1XmCJQq/TLwmLAWXnTBwMdPB/c0TTRydH04CxD6LUILua2gEOJ6fvBdfJAwcAyZjxOhCau7XLrEP5DH/jiaaZBuYZrxRWJYsYhPLnRwqLAeKOpmxf95KWxN6pf+ugY9RPY5kMINKlSfOoAAIqCMzJOSp43OO8k3L6j55KYgUbi7Ce5esw6rxShzb4hJt05WRKLEpIfq/fSeCJhUZy2GLyjezr31ao7pSiWEdSQxuDD76z8rtPm2t2RGeMMHTbggLItWpHxv6ydSsgfn74t1FtrbhFagwkHjhaTHfb+n+J8TeRP9wKB7PsYqjbGEBuKKX8MRa2a4czsFDLogSfQRddlMstEZfwg0z8VdDol1SSngj3havqZkzpZ+qA8Rb35jWVyn/pql+VnQHKa/Y+pF+qstd3ptk//Rx1g6lueplf+CadvJWRKvGEjhjW46dV7w0vO7EvOh3JydyQUD0KdcRl7YG6jm010Vaj5nnbYB9iw37XHpxSeRCxsEzWFHN7MjjxBZMAzFS8esEE/UygUfuB3q3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(8676002)(66556008)(66476007)(66946007)(16576012)(83380400001)(316002)(8936002)(31686004)(54906003)(6916009)(186003)(86362001)(53546011)(508600001)(36756003)(2616005)(2906002)(26005)(38100700002)(4326008)(6486002)(5660300002)(7416002)(31696002)(956004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aHBCQno1ZXdseVViYU56eXp4Ymc4b0xqNWJSSVZXaXZVSTAvdWVOMEtablpt?= =?utf-8?B?WFd0bkQ1b1FUaGppQ005bVhETFR1V3F5dkFMZTNkbjBOdllzcTBaemo4RHp2?= =?utf-8?B?V3hRMVplM1M0T1hNMk9HRW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V2tyNlRw?= =?utf-8?B?R0xEUzViK1JSanlxeGJVRlN1dkZaNzNsU1RoL2Z0SU1qYkttN2NTc2NYQnd5?= =?utf-8?B?SVg5cGFDdU1na2tqZHVWREFPWTNRWUFQbUFBajcvR0JieXNNS0lRbjlQeW5Z?= =?utf-8?B?TzZmMUkzaEdRTEM0eFR5eHlKTERzOU5sd0ZCTmhOb3d1Q0RqYXMxNG00NzdY?= =?utf-8?B?NmF1Z3IzWUhOWVZVOEl2cTRoMW1JcGxaVyswWWdpdENUY2F2cFc1cGlCbm1a?= =?utf-8?Q?N3Kz24k9zjSfQKzQJcGaad0=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e49d38ea-0ff1-4ee6-5632-08d999b3435f X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 01:35:46.0094 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9p8rAsvQJWY4oDjDDqgdAq2oW5g4/iJy1HtnCkbvGhfG2Wc0giznwiGBNLIfAdUy4c5gPVT+3mC+qjVGbXZOGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3464 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/27/21 18:20, John Hubbard wrote: >>> But it's still not good to have this function name doing something completely >>> different than its name indicates. >> >> I see, I can rename it to: 'set_page_recounted/get_page_recounted' ? >> > > What? No, that's not where I was going at all. The function is already > named set_page_refcounted(), and one of the problems I see is that your > changes turn it into something that most certainly does not > set_page_refounted(). Instead, this patch *increments* the refcount. > That is not the same thing. > > And then it uses a .config-sensitive assertion to "prevent" problems. > And by that I mean, the wording throughout this series seems to equate > VM_BUG_ON_PAGE() assertions with real assertions. They are only active, > however, in CONFIG_DEBUG_VM configurations, and provide no protection at > all for normal (most distros) users. That's something that the wording, > comments, and even design should be tweaked to account for. ...and to clarify a bit more, maybe this also helps: These patches are attempting to improve debugging, and that is fine, as far as debugging goes. However, a point that seems to be slightly misunderstood is: incrementing a bad refcount value is not actually any better than overwriting it, from a recovery point of view. Maybe (?) it's better from a debugging point of view. That's because the problem occurred before this code, and its debug-only assertions, ran. Once here, the code cannot actually recover: there is no automatic way to recover from a refcount that it 1, -1, 2, or 706, when it was supposed to be zero. Incrementing it is, again, not really necessarily better than setting: setting it might actually make the broken system appear to run--and in some cases, even avoid symptoms. Whereas incrementing doesn't cover anything up. The only thing you can really does is just panic() or BUG(), really. Don't get me wrong, I don't want bugs covered up. But the claim that incrementing is somehow better deserves some actual thinking about it. Overall, I'm inclined to *not* switch anything over to incrementing the refcounts. Instead, go ahead and: a) Add assertions up to a "reasonable" point (some others have pointed out that you don't need quite all of the assertions you've added). b) Remove set_page_count() calls where possible--maybe everywhere. c) Fix any bugs found along the way. d) ...but, leave the basic logic as-is: no changing over to page_ref_inc_return(). Anyway, that's my take on it. thanks, -- John Hubbard NVIDIA