From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F169BC433E2 for ; Fri, 11 Sep 2020 17:34:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6712222204 for ; Fri, 11 Sep 2020 17:34:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DjdeNCFu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6712222204 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9AA1E6B005A; Fri, 11 Sep 2020 13:34:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 933466B005C; Fri, 11 Sep 2020 13:34:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 824066B005D; Fri, 11 Sep 2020 13:34:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 699886B005A for ; Fri, 11 Sep 2020 13:34:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 26B98180AD811 for ; Fri, 11 Sep 2020 17:34:51 +0000 (UTC) X-FDA: 77251480782.01.clock31_48082ed270f0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id DCC141004F625 for ; Fri, 11 Sep 2020 17:34:50 +0000 (UTC) X-HE-Tag: clock31_48082ed270f0 X-Filterd-Recvd-Size: 4437 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 17:34:50 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id v23so13166793ljd.1 for ; Fri, 11 Sep 2020 10:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YvxJxAVSuTWGuM+h5vWmwMjDvCcq+fuIG/RpHMBhiPs=; b=DjdeNCFutxyY9lDGpo4tFW8pqf/M17W5kAPM89h9TqBR2uaWfihqpGCbaNPKZxfls0 0bABOX684WC5YsfIb7zyUlk3EgTVWeMu3njWTFl+WEbWPQVJ3cU58u/pkwR9Gp1C59zD jveob89SONHFkOfFty0NocCD96mB6m00PYLWCZaUffQPzuBBdur9dQfNzEOMI5ehv5fS BN5yLT2kL3BeNomfCFI2YhKezzPerCgL9j30JnCkVzZVLd0YG+7anh+qQkw1wAHsXm/s E7SR8zscAhTP17zi3NQA/JdSzDV2AgwMDFtVTIMBH6kZFp8fHGHyQI+80Bnj3osHYa6P T8AA== 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=YvxJxAVSuTWGuM+h5vWmwMjDvCcq+fuIG/RpHMBhiPs=; b=UYUeHNn9Ar6Ce66Y0GC95XBPw7UvPTZtEAZoTxL3VnzICdMP23CwA3wcXpdfwH72Wj EVOL6Q3zVYA0iIYr9fzWeyI0rdXSKAVHZcpOGU6mac1FO+vszRz1cRQRJD29fEKti2PS WKWDwFZirrLOEA5YkSfYWsKRAI34WkbIAuCnsS8l2LE6t6hLWx0NQoPUyCHDv3XmKS0f uD/f31GhuyEOK5Gb0AQhK23E7q5wukrNbNiz0dQiSlbQrPQlfjEBjnOHYhCn8ki7Gn6d 6mOFCpp9ppD4B5+QU9i5RvqDrr3Gd4R22niQ4gfSdgMEad5D61uFfGRRlZXUzOA/mDuj oVdA== X-Gm-Message-State: AOAM5307Jb1jOtHoUYB8heKYDwgqgn3nTsuvdeO90llt6wadI/WGliRZ Sreu2qA0aFRSOyvQI99r8AW7ZfG0o8DISl0gt3aD8Q== X-Google-Smtp-Source: ABdhPJwUszV8INh0bBpEkUCldZXG88nIVbGF+zdvu4Zrl3qQPVV4Bf3d9LVe5G6/zxlTKBpnc7U+2GaJDYZAtwkztZM= X-Received: by 2002:a2e:7c09:: with SMTP id x9mr1115333ljc.192.1599845688649; Fri, 11 Sep 2020 10:34:48 -0700 (PDT) MIME-Version: 1.0 References: <20200910202659.1378404-1-guro@fb.com> In-Reply-To: <20200910202659.1378404-1-guro@fb.com> From: Shakeel Butt Date: Fri, 11 Sep 2020 10:34:36 -0700 Message-ID: Subject: Re: [PATCH rfc 0/5] mm: allow mapping accounted kernel pages to userspace To: Roman Gushchin Cc: Andrew Morton , Linux MM , Johannes Weiner , Michal Hocko , Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: DCC141004F625 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 10, 2020 at 1:27 PM Roman Gushchin wrote: > > Currently a non-slab kernel page which has been charged to a memory > cgroup can't be mapped to userspace. The underlying reason is simple: > PageKmemcg flag is defined as a page type (like buddy, offline, etc), > so it takes a bit from a page->mapped counter. Pages with a type set > can't be mapped to userspace. > > But in general the kmemcg flag has nothing to do with mapping to > userspace. It only means that the page has been accounted by the page > allocator, so it has to be properly uncharged on release. > > Some bpf maps are mapping the vmalloc-based memory to userspace, and > their memory can't be accounted because of this implementation detail. > > This patchset removes this limitation by moving the PageKmemcg flag > into one of the free bits of the page->mem_cgroup pointer. Also it > formalizes all accesses to the page->mem_cgroup and page->obj_cgroups > using new helpers, adds several checks and removes a couple of obsolete > functions. As the result the code became more robust with fewer > open-coded bits tricks. > > The first patch in the series is a bugfix, which I already sent separately. > Including it in rfc to make the whole series compile. > > This would be a really beneficial feature. I tried to fix the similar issue for kvm_vcpu_mmap [1] but using the actual page flag bit but your solution would be non controversial. I think this might also help the accounting of TCP zerocopy receive mmapped memory. The memory is charged in skbs but once it is mmapped, the skbs get uncharged and we can have a very large amount of uncharged memory. I will take a look at the series.