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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95342C25B08 for ; Fri, 5 Aug 2022 13:26:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E422E8E0002; Fri, 5 Aug 2022 09:26:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF1538E0001; Fri, 5 Aug 2022 09:26:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C91E88E0002; Fri, 5 Aug 2022 09:26:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B987A8E0001 for ; Fri, 5 Aug 2022 09:26:09 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 93A561C72EB for ; Fri, 5 Aug 2022 13:26:09 +0000 (UTC) X-FDA: 79765612458.02.03C2B21 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id D40E4180149 for ; Fri, 5 Aug 2022 13:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659705968; 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=mJBXhzmt1GniFe2smeou8x6jmkkaotxI6ROvs4HpGEk=; b=bpkEz2iOjvmYkH6VqnaDfNHgqGT0ELkwEQZ5jkL78af+dgRHHpcOoV2AW8YnkXOv88YBxe pow/GbzO5yzeeGp0L+WWtlFxnAPz5tYfNIF5Zj0kRdan0EV2SfzYBgl1LHxlv+mF8DOQFj 5xAP6JdktNElst8eIPeD5hyZxMDL9xA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656--9uLtbW6MLi7rAaBgBW3yw-1; Fri, 05 Aug 2022 09:26:07 -0400 X-MC-Unique: -9uLtbW6MLi7rAaBgBW3yw-1 Received: by mail-wm1-f71.google.com with SMTP id v130-20020a1cac88000000b003a4f057ed9fso1270449wme.7 for ; Fri, 05 Aug 2022 06:26:06 -0700 (PDT) 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; bh=mJBXhzmt1GniFe2smeou8x6jmkkaotxI6ROvs4HpGEk=; b=mrkV4JRKTA2DrqEt342UPa/e6G/Og0GmqfcZS0+sC5/K/awiZUBo1ouGNXeyLR5xy7 ygFNBoWGBtcJtmwW83+sNiopJ0OB3eKFUYeGQcRrnsvLX9U0CxxtQNcllqdI0UCFYoUw KSGj2Ce1HqRj9REKOq8eSkiqOtqoGqy3CUP9w7F8IfS4P9Hf/nnoAHuTbLdAEh5PkC+k 4Hjw8gSrhdbBPU8PCqP9fHkmNPJfWvFM5uD+8JBuawKZrEgC21ySGBCDoF11/UxVkVfA z5Jfi5hmwIH3wVIWeZbv84+9r3k5FECOUF0P2IENC8iePg7XrgXNl0vpBoB153hN6o5d gfzA== X-Gm-Message-State: ACgBeo1MHzjQaiTOhplZ7iOnyrJED1EyDXKHQPfCK3Y8lYRmZPslssFA 8MrZZMfS72ynY5iKibGAaShsR8t1Ody4SugWuGXlwz1envSOE1Ct7Yyi8FB70DeY4QPCoOFSYOG 7hoZTbCzvRYQ= X-Received: by 2002:a5d:588f:0:b0:220:761a:6894 with SMTP id n15-20020a5d588f000000b00220761a6894mr4409191wrf.406.1659705965758; Fri, 05 Aug 2022 06:26:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ajxOjPYt9fURAvT4aPqpXXmNPivXi3/PkheqDod4RApDXYAPhtZxZHk1xvMFDF/irKdR08g== X-Received: by 2002:a5d:588f:0:b0:220:761a:6894 with SMTP id n15-20020a5d588f000000b00220761a6894mr4409161wrf.406.1659705965445; Fri, 05 Aug 2022 06:26:05 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:fb00:f5c3:24b2:3d03:9d52? (p200300cbc706fb00f5c324b23d039d52.dip0.t-ipconnect.de. [2003:cb:c706:fb00:f5c3:24b2:3d03:9d52]) by smtp.gmail.com with ESMTPSA id o6-20020a05600c4fc600b003a32490c95dsm9887725wmq.35.2022.08.05.06.26.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 06:26:05 -0700 (PDT) Message-ID: Date: Fri, 5 Aug 2022 15:26:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v7 04/14] mm/shmem: Support memfile_notifier To: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-kselftest@vger.kernel.org Cc: Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song References: <20220706082016.2603916-1-chao.p.peng@linux.intel.com> <20220706082016.2603916-5-chao.p.peng@linux.intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220706082016.2603916-5-chao.p.peng@linux.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659705968; a=rsa-sha256; cv=none; b=8lesZD6jgj97lYGbniuobFdF2SgbsDS6fGM6OHZLMGG7Z2nLlu26WA3GoW3BRRxpvEUp7p l0FtKMq5n/2ee9AdE5pGmv4ViH9LhFzW+CyI9i9qZVUPAj7EzH+qGjK2tjXF0qyA48ClvW R/Gw/jxCEfltWwxW4lJHQvooXG3qSak= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bpkEz2iO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659705968; h=from:from:sender: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:dkim-signature; bh=mJBXhzmt1GniFe2smeou8x6jmkkaotxI6ROvs4HpGEk=; b=lJ4ZSHn//HB7GMSxJIjcmNoe0EF5oZDV1X4qE3dfVR9A5Lc7QyinryFE+48VYzAAxIzVAe BsoCQa2L42YEXxHLzD1J9isMpmZthITI7dclxqlpMTXsfQ9uKRpaErP/LsmloFhziCZBkW JOeqmBLZ9dzWncaNrdo2q9A7EBL95+E= X-Stat-Signature: xd8mxpnyyii6ezp139sqe6ra1p46ubza X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D40E4180149 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bpkEz2iO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspam-User: X-HE-Tag: 1659705968-849023 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 06.07.22 10:20, Chao Peng wrote: > From: "Kirill A. Shutemov" > > Implement shmem as a memfile_notifier backing store. Essentially it > interacts with the memfile_notifier feature flags for userspace > access/page migration/page reclaiming and implements the necessary > memfile_backing_store callbacks. > > Signed-off-by: Kirill A. Shutemov > Signed-off-by: Chao Peng > --- [...] > +#ifdef CONFIG_MEMFILE_NOTIFIER > +static struct memfile_node *shmem_lookup_memfile_node(struct file *file) > +{ > + struct inode *inode = file_inode(file); > + > + if (!shmem_mapping(inode->i_mapping)) > + return NULL; > + > + return &SHMEM_I(inode)->memfile_node; > +} > + > + > +static int shmem_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, > + int *order) > +{ > + struct page *page; > + int ret; > + > + ret = shmem_getpage(file_inode(file), offset, &page, SGP_WRITE); > + if (ret) > + return ret; > + > + unlock_page(page); > + *pfn = page_to_pfn_t(page); > + *order = thp_order(compound_head(page)); > + return 0; > +} > + > +static void shmem_put_pfn(pfn_t pfn) > +{ > + struct page *page = pfn_t_to_page(pfn); > + > + if (!page) > + return; > + > + put_page(page); Why do we export shmem_get_pfn/shmem_put_pfn and not simply get_folio() and let the caller deal with putting the folio? What's the reason to a) Operate on PFNs and not folios b) Have these get/put semantics? > +} > + > +static struct memfile_backing_store shmem_backing_store = { > + .lookup_memfile_node = shmem_lookup_memfile_node, > + .get_pfn = shmem_get_pfn, > + .put_pfn = shmem_put_pfn, > +}; > +#endif /* CONFIG_MEMFILE_NOTIFIER */ > + > void __init shmem_init(void) > { > int error; > @@ -3956,6 +4059,10 @@ void __init shmem_init(void) > else > shmem_huge = SHMEM_HUGE_NEVER; /* just in case it was patched */ > #endif > + > +#ifdef CONFIG_MEMFILE_NOTIFIER > + memfile_register_backing_store(&shmem_backing_store); Can we instead prove a dummy function that does nothing without CONFIG_MEMFILE_NOTIFIER? > +#endif > return; > > out1: -- Thanks, David / dhildenb