Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1479691rwe; Thu, 1 Sep 2022 20:47:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/JuwIpGQTQJzIcqrmNMBCLTtmAXWfBFn8Y99oaW7ll8R84k79KdVq/QWtZYRpeiocJddC X-Received: by 2002:a17:906:f88f:b0:731:463d:4b15 with SMTP id lg15-20020a170906f88f00b00731463d4b15mr25620982ejb.299.1662090434903; Thu, 01 Sep 2022 20:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662090434; cv=none; d=google.com; s=arc-20160816; b=OOj4wRq2xKyCum6ztyYNRbjaeGnr+aU8BbB/SlZkp68f5Jt/gPIdqXd3SlV0yi3D66 C9on3+0LwyjI3hcjdrn+qg7cMCghHzAcQl55bgT7/pS81p3Tpb/c1Zx2Jw36sXc762f5 Z52CIjrA7YYQ6binkG84q3Mr2zF42vGR6h2cISkXH5f+d1biiTOBSXjV0DB267gbPq/b OyfRSD7Mcr3byHgSExjhxqdFtHA3mnXAcxV2Td8t7CrEjTsKp1+ESIMM9aWVdMBlwabx 7IMB0cVniPlZvnMHVELnMefROXeDdtCFkI+b25Y2Me4M9h/qg2OaWUAPD9LXIGZzc55/ Gf4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=shz1MJujjzqiNwugBIDcBsPwYPc3SVzREMOMkqsy7Mk=; b=P4aSGj15gUoNlq69b4JIRzsxtIHO6l735dzFbtORGjiGEsMFxZCgd3mI2o2EcnQLPU A3KVnDfaMclrbJWVQdgpv3jIR/M/nc9CtXxlIILU3q1MkEjbTTgFJGAM/J8Xqe+LRkqT oGH0LU5GmhwoEg+36Ykg1FijQ9Xj1MkI3UZo/eFcW/pXgU0l9aKd6C4NLrpVO5zccfKG UzVjNpy30EjP4YRT6r7kHmdTobfUBFwKPaAAfchFBJUrwijRyL0Ch7ib1e5IN3fDmFTP vQuax1HhlXqvlGcoTbo3UYBBUkGUeaWVs8QSYdWclWOJHsqHihyYFioLCnL5H6+QlGvL snqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=w8zTqe7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a170906558400b0073d89516878si713012ejp.241.2022.09.01.20.46.48; Thu, 01 Sep 2022 20:47:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=w8zTqe7j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235315AbiIBDbn (ORCPT + 99 others); Thu, 1 Sep 2022 23:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235300AbiIBDbC (ORCPT ); Thu, 1 Sep 2022 23:31:02 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FE9AB063 for ; Thu, 1 Sep 2022 20:31:01 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id m2so661839pls.4 for ; Thu, 01 Sep 2022 20:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date; bh=shz1MJujjzqiNwugBIDcBsPwYPc3SVzREMOMkqsy7Mk=; b=w8zTqe7jLtPspiEBjz+Fy4fnP6CRLP/1zB1TYddtfRvPRf6HmPkOhDjjui66WN2vsl 5IjdUYxKnnoMusvxY/mOH9TD6PkP0ZcdcNPwGreeU6bbLuIBySqYMjVzFdaEv0V86kHy pRzBdIR3YkpGmIYlHpQDxZhmRZ72RRgFTm51BCNCOvy5ir+Mv2OIiiNBEEtYNav77mUF mbHV4wPilqz1NqoKMoWYS9n2nLpkfXWHCOkA/MkS5si5zhMesHK7y5M6S0/swB5oGNJp Vho54MFRdGsDtTej4LYmrHru82H6nWe9gB2JJQhofQYoZ/Tj2mO1Q5xsj0DzIRYpaQd7 /r3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date; bh=shz1MJujjzqiNwugBIDcBsPwYPc3SVzREMOMkqsy7Mk=; b=Ew65zJ/dL3/eNBnoDiToBJ5+YWvQCYxNOh843AhS0iC+X+zGZ5Cgsc7rXqcOdNl020 jAi9TJjkQKO1nSygeqDghRE8AdYlwMOAf51CigTXrcQTDVK5JJAStxnmLKk/1yvQ48/f u6t9rO/9NYlHF/WPZRcszzZhtbkeaIe6kODMxsfsxtn+2CQ7OS/vmqPffCHV/11spUl1 CqYKwcOfYfGT1n0FM92b2kafTWTeZ49CbD7JDUDrmiY31pACDhRM1Qz6FpInYq2INIDo SlUgRlxbfrtD907iiJZHiOs9tt/zDM7PTnm1rbtPR5eC+pbwj6Ohiiudc5XqERX5GjOs lhuw== X-Gm-Message-State: ACgBeo2Ngfy4uduc/Z7NESLCXdPJrCB6prGdzeu1+0D8gOA8MYRx5drC E5aazMl8DwexT9iVynpsLa+E0dXmDaswIA== X-Received: by 2002:a17:90a:4d8d:b0:1fa:9cc6:3408 with SMTP id m13-20020a17090a4d8d00b001fa9cc63408mr2434860pjh.245.1662089460803; Thu, 01 Sep 2022 20:31:00 -0700 (PDT) Received: from [10.255.237.132] ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id x13-20020a17090a1f8d00b001f510175984sm4090447pja.41.2022.09.01.20.30.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Sep 2022 20:31:00 -0700 (PDT) Message-ID: <4a62a93c-683a-0515-2033-26c59b3b6f20@bytedance.com> Date: Fri, 2 Sep 2022 11:30:53 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v2] iommu/iova: Optimize alloc_iova with rbtree_augmented To: John Garry , joro@8bytes.org, will@kernel.org Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, robin.murphy@arm.com, xieyongji@bytedance.com, Ethan Zhao References: <20220824095139.66477-1-zhangpeng.00@bytedance.com> <06c215c6-cbae-d6b9-312c-6535e51a3128@linux.intel.com> <486fcde8-e9f5-e40c-db5d-fd3ade59b267@bytedance.com> <4527c925-076b-a477-4ff8-697d75f16761@bytedance.com> <1351998d-4fd7-dffb-c1fa-a0b1ca759123@huawei.com> From: Peng Zhang In-Reply-To: <1351998d-4fd7-dffb-c1fa-a0b1ca759123@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > If you really have a performance issue with alloc_iova_fast() -> > alloc_iova() then I suggest that you consider trying to use > dma_opt_mapping_size() to teach the DMA engine driver to not create > requests whose overall size exceeds to the rcache limit. Yes. But I don't think it essentially solves the problem. A library for users should run stably ant it shouldn't hold the spinlock for a long time in some cases. It can even be said to be a bug. Like this: [Wed May 25 05:27:59 2022] watchdog: BUG: soft lockup - CPU#58 stuck for 23s! [Wed May 25 05:27:59 2022] Call Trace: [Wed May 25 05:27:59 2022] alloc_iova+0xf2/0x140 [Wed May 25 05:27:59 2022] alloc_iova_fast+0x56/0x251 Now we avoid this problem with iommu=pt, but it didn't solve the problem. Thanks, Peng