Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 309DDC636D4 for ; Tue, 31 Jan 2023 14:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbjAaOBN (ORCPT ); Tue, 31 Jan 2023 09:01:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231407AbjAaOBL (ORCPT ); Tue, 31 Jan 2023 09:01:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF440518CA for ; Tue, 31 Jan 2023 06:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675173614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sW7aiMox0CriK8aU+HN+jb3vaXSIy6HBnrk2aPiMthI=; b=hNBqq1VaLUmj3Gv1bRG7q+5EQCO429IY7U/08wZlnbsDbr814ZlRjHZ0QxfnaGFtdWzpni tDLuxG8mKUlU8g0iKrrkVJslJvv5Pg/tJEf+A+xr1EDIPxSAPiLpbQV/Nn1IDqcMMhscrK f3/M7EcB/tK+JCmXdbEaboSZ0rFgfhs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-635-ex_gDDw1MTSG51iMe9dUbg-1; Tue, 31 Jan 2023 09:00:12 -0500 X-MC-Unique: ex_gDDw1MTSG51iMe9dUbg-1 Received: by mail-wr1-f72.google.com with SMTP id e9-20020a5d6d09000000b002c172f173a9so301443wrq.17 for ; Tue, 31 Jan 2023 06:00:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sW7aiMox0CriK8aU+HN+jb3vaXSIy6HBnrk2aPiMthI=; b=Z86W/PjIKYGnpOap9AFIAUyV7T2ODF4WoOxXXn4WmLcmXpNDOkOcH9IZ/0ShoH7HyY 6pAvBMffxeb42w/4mSGLq3X5PgWgGFN9n0wcUCwWPFCHe50Rw3zQThUV4/dlZ9kyjGGH MJfnpLmWpZHV5PsZhZjgzKVW94hGkEn+Sh+T0wojZPZh9h9Go6k1OiJYI+QKqQK65R37 614VXk3gBx1rUNkXu/EKyoyRUppmEIbOwnWwqLmR6+hJeNIIJv7ZO2OM6u7lSvTtPM/Z DV8rT2zzm6m84IsfoUcddtoy73wITaK78XcGsugAdTLHKgpRVltpALTII39a+03ER64D z0nA== X-Gm-Message-State: AO0yUKWHCfTZJOzpRv/n10LBxjBpZN5IhkkOsj65R4o49J5f0v0aceIK lrmiFc60SYqzBQ/RI009UWEoYM5shDoEdmNmjIdQJrhgcujPrPZZENKXgKl4j1YaFWRfse9bqHE OpNhZrT56fTGu3NXtFp003rBw X-Received: by 2002:a05:600c:3b84:b0:3dc:1031:14c4 with SMTP id n4-20020a05600c3b8400b003dc103114c4mr3752227wms.14.1675173611365; Tue, 31 Jan 2023 06:00:11 -0800 (PST) X-Google-Smtp-Source: AK7set94yYHCQtMUhLwwFZW2Tw85+OPCk5GgL8jU/FYp0b92bP94albwy2k0jgp6h4ZElMMLuWMq1g== X-Received: by 2002:a05:600c:3b84:b0:3dc:1031:14c4 with SMTP id n4-20020a05600c3b8400b003dc103114c4mr3752186wms.14.1675173611028; Tue, 31 Jan 2023 06:00:11 -0800 (PST) Received: from ?IPV6:2003:d8:2f0a:ca00:f74f:2017:1617:3ec3? (p200300d82f0aca00f74f201716173ec3.dip0.t-ipconnect.de. [2003:d8:2f0a:ca00:f74f:2017:1617:3ec3]) by smtp.gmail.com with ESMTPSA id e38-20020a05600c4ba600b003dc434900e1sm11512963wmp.34.2023.01.31.06.00.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Jan 2023 06:00:10 -0800 (PST) Message-ID: <658eda9c-d716-fcb7-ba0c-b36f646195f1@redhat.com> Date: Tue, 31 Jan 2023 15:00:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [RFC PATCH 01/19] mm: Introduce vm_account Content-Language: en-US To: Alistair Popple , linux-mm@kvack.org, cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jgg@nvidia.com, jhubbard@nvidia.com, tjmercier@google.com, hannes@cmpxchg.org, surenb@google.com, mkoutny@suse.com, daniel@ffwll.ch, linuxppc-dev@lists.ozlabs.org, linux-fpga@vger.kernel.org, linux-rdma@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org, io-uring@vger.kernel.org, bpf@vger.kernel.org, rds-devel@oss.oracle.com, linux-kselftest@vger.kernel.org References: <748338ffe4c42d86669923159fe0426808ecb04d.1674538665.git-series.apopple@nvidia.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <748338ffe4c42d86669923159fe0426808ecb04d.1674538665.git-series.apopple@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24.01.23 06:42, Alistair Popple wrote: > Kernel drivers that pin pages should account these pages against > either user->locked_vm or mm->pinned_vm and fail the pinning if > RLIMIT_MEMLOCK is exceeded and CAP_IPC_LOCK isn't held. > > Currently drivers open-code this accounting and use various methods to > update the atomic variables and check against the limits leading to > various bugs and inconsistencies. To fix this introduce a standard > interface for charging pinned and locked memory. As this involves > taking references on kernel objects such as mm_struct or user_struct > we introduce a new vm_account struct to hold these references. Several > helper functions are then introduced to grab references and check > limits. > > As the way these limits are charged and enforced is visible to > userspace we need to be careful not to break existing applications by > charging to different counters. As a result the vm_account functions > support accounting to different counters as required. > > A future change will extend this to also account against a cgroup for > pinned pages. The term "vm_account" is misleading, no? VM_ACCOUNT is for accounting towards the commit limit .... -- Thanks, David / dhildenb