Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3200169rdb; Thu, 16 Nov 2023 03:11:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/QWrTapHrgvs3lOCtmRsj5dy3L0ORNke2IIhPmJv1ldrGWlidSKasdsBWqrL3PVTnN+Q4 X-Received: by 2002:a9d:6f82:0:b0:6c0:ef3c:5ab4 with SMTP id h2-20020a9d6f82000000b006c0ef3c5ab4mr8799522otq.0.1700133112582; Thu, 16 Nov 2023 03:11:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700133112; cv=none; d=google.com; s=arc-20160816; b=qaEQTSNqmYGZLpTVdxmeYRX4+1mKZJ1/kb/zzQE8WhlHiGgKoTtZbdemR1ITL253e6 It1qN2JgvowfX5NyR572SD5UgiDTMqFurY+2vC2O9TdWtFbKQoaayL/yJwJQtF88Lr3z F1sqledteBZO4Xla4w8rdZ/beJtzm9iAyRdrskGFTnatxmMSB+W4TsPk6CMIns/bOE4q ak8UNT/E5z31ZR/TKNHsq8twBXDqNGbGSzw8Spf7WZd6nlaOnQQBVEa7zI2Q6Ml0pi2u OJgmONVq+CvwaNTOBQLgBWG3Ntve51Y3gnt0iqKOJ8r5xp4sCabY+i6DXtydJ+EjFlP8 uhfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qa4zNvD3R63oZSQAhdocCl4kKoiV4mt+N880Q8UM01c=; fh=L4qqzbCn2hRWqaC4W5/ZJuFRj5qYfh7FACdrLnc3uzA=; b=AIxHvTIkdW1cAc7hkK8yJ7UA96GF4Pe4QWl0GaAvOXog4RDYpZV0I5pOzNIRSARLM2 ZlFjDiDZCz1Q04kFswl6D8QQNiDTQ08OKtUST4RfWSIVN2L2Z9R+4GP9WtenwpdU3Epj I1mkoZJ8lLWRL9DIiWGsbOTUFhSPqsRWNAbxDncg/cxIpO5pmgA4Zf+OhNEsWBRTqxLx I2Dk8oh9odCs72iDcQfFeP8ccvD8YWHwxDDNR5++A1XJi/cfpAmSIgjsCsKhRjn5oxLi Zkigfkvel9lbs5kggrsRSo8WXMM4g91BNQtcn7RrNaokpJ4ONeahR2hkwXtqALIK0OgX I1NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c2-20020a633502000000b005ab2613a571si12246265pga.495.2023.11.16.03.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:11:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E3DCB80ECAF9; Thu, 16 Nov 2023 03:11:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235700AbjKPLLb (ORCPT + 99 others); Thu, 16 Nov 2023 06:11:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345158AbjKPLL1 (ORCPT ); Thu, 16 Nov 2023 06:11:27 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C737CC1; Thu, 16 Nov 2023 03:11:21 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SWHKZ5v5XzMmsp; Thu, 16 Nov 2023 19:06:42 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 16 Nov 2023 19:11:19 +0800 Subject: Re: [PATCH RFC 3/8] memory-provider: dmabuf devmem memory provider To: Mina Almasry CC: Jason Gunthorpe , Jakub Kicinski , , , , , Willem de Bruijn , Kaiyuan Zhang , Jesper Dangaard Brouer , Ilias Apalodimas , Eric Dumazet , =?UTF-8?Q?Christian_K=c3=b6nig?= , Matthew Wilcox , Linux-MM References: <20231113130041.58124-1-linyunsheng@huawei.com> <20231113130041.58124-4-linyunsheng@huawei.com> <20231113180554.1d1c6b1a@kernel.org> <0c39bd57-5d67-3255-9da2-3f3194ee5a66@huawei.com> From: Yunsheng Lin Message-ID: <28b65d3b-4df4-ce8b-00b6-abe565c0ab70@huawei.com> Date: Thu, 16 Nov 2023 19:11:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 16 Nov 2023 03:11:50 -0800 (PST) On 2023/11/16 1:44, Mina Almasry wrote: > On Wed, Nov 15, 2023 at 1:21 AM Yunsheng Lin wrote: >> >> On 2023/11/14 21:16, Jason Gunthorpe wrote: >>> On Tue, Nov 14, 2023 at 04:21:26AM -0800, Mina Almasry wrote: >>> >>>> Actually because you put the 'strtuct page for devmem' in >>>> skb->bv_frag, the net stack will grab the 'struct page' for devmem >>>> using skb_frag_page() then call things like page_address(), kmap, >>>> get_page, put_page, etc, etc, etc. >>> >>> Yikes, please no. If net has its own struct page look alike it has to >>> stay entirely inside net. A non-mm owned struct page should not be >>> passed into mm calls. It is just way too hacky to be seriously >>> considered :( >> >> Yes, that is something this patchset is trying to do, defining its own >> struct page look alike for page pool to support devmem. >> >> struct page for devmem will not be called into the mm subsystem, so most >> of the mm calls is avoided by calling into the devmem memory provider' >> ops instead of calling mm calls. >> >> As far as I see for now, only page_ref_count(), page_is_pfmemalloc() and >> PageTail() is called for devmem page, which should be easy to ensure that >> those call for devmem page is consistent with the struct page owned by mm. > > I'm not sure this is true. These 3 calls are just the calls you're > aware of. In your proposal you're casting mirror pages into page* and > releasing them into the net stack. You need to scrub the entire net > stack for mm calls, i.e. all driver code and all skb_frag_page() call > sites. Of the top of my head, the driver is probably calling > page_address() and illegal_highdma() is calling PageHighMem(). TCP > zerocopy receive is calling vm_insert_pages(). For net stack part, I believe your patch below is handling to aovid those mm calls? I don't include it in this patchset as I thought it is obvious that whatever the proposal is, we always need those checking. Maybe we should have included it to avoid this kind of confusion. https://lore.kernel.org/all/20231106024413.2801438-10-almasrymina@google.com/ For driver part, I was thinking if the driver supports devmem, it should check that if it can call page_address() related call on a specific 'stuct page', or maybe we should introduce a new helper to make it obvious?