Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp137976lqq; Wed, 12 Jun 2024 20:28:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtvxaDclPW6nRZbY3zAPW8I5eMPchrv1JyQpPv9vdKxUnqkITbQsfets6sPuZOhZ1H/CpujZ7D3NN6UQb5Xp9+WmbvxjJFWRqGFxsyIA== X-Google-Smtp-Source: AGHT+IGYSgDmKskk1SichiihKAjCs8/g4zy0lCSa4KrzWsDB54xLEL6qRsMM83HqgIMt4j2OCwGD X-Received: by 2002:a9d:7387:0:b0:6f9:57e5:af05 with SMTP id 46e09a7af769-6fa1be56cbamr3634757a34.2.1718249328293; Wed, 12 Jun 2024 20:28:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718249328; cv=pass; d=google.com; s=arc-20160816; b=0SkpATaNCJEZAdWO5oFrBj/+Sb9a29aUcr2Ers2NsVrY0mOrXfsDbz0N82Fw3KVGiH Cc++I19HzcB+5WJU5RSvXcxRPeVFZZ7fAp9W0xa9kJsRHxXvkqm8jwvZM8M6dja0jpr+ 4P7qK1sYmPoctLyg+1DYghMEhmKYYp9028nGBtTCA6QXTA0ZMFRYqA+i2y/L3ZXg3Q4K 0UT0Gf195M7UWRqPnGVW6iloa7+/Eztd+s0QwvCFaokZY7EsCyKohQxMvnq43JQ3ltJX YLBy57kP8qZSwYp3SjWeCJ5Rq+cy3JYwcM8+mlXoFc/aGfpvBY/vXSWcEcN5+Uy4jFI+ ks0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=1lhNM4y2L46tcjO0HaVOmUt/V/J9/oSem/zD16s3nQU=; fh=YOdnKfPEQrMNtZVxpEZV2UV9P3dRlX0cHDWLGXOhLoo=; b=P3bwfzSF5CRCz6N09ao/SFIpFPFYC6h0qYXzemyokKwu6JefLMd9lCQTdpKMzAuQfR T/JzduM5EKOL+cMxXM+PplLB+/7oiALsE9CNu8ZlDvV6dkWDqAf78czAHMNNj9c06mly CzcCoIoL+B/XLB7NIEiYF/DVvR9Awjbbju44wfV6da2QEVAJ4o1KfcJL2sSIMIxU4nLO tzNiIGoE51f+pW5OTbz7Fp5T6HiMXvml5RYVcCJq7eo4w4fqMbqMwp/GqiY7WXK5pde7 SYjVI3iiIxOfqB48/wefdFetblyIs5bvIBFxFXWnVzAMyOLmOAec+DEE0f1Zk81uChb4 0Sxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-212521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee5496f53si419279a12.651.2024.06.12.20.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 20:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-212521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB7D92824D0 for ; Thu, 13 Jun 2024 03:28:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5EA331304BD; Thu, 13 Jun 2024 03:28:41 +0000 (UTC) Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 544A1748E for ; Thu, 13 Jun 2024 03:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718249320; cv=none; b=Zh3yJOZynTz5eOVGnCs0tVZH54g3/pp9UYqd5VkULV0mElhoszHcdP5XHnnvemKmq95HPB+eWHHP+DSWDGat/Gsnktm8ZCfAEZ8MWjsUQ5Nk4jcufZ3fb3+gB0uBKTd1c5YYXRJOU815F++Eu/mrAF/TXHC5MnRAaJFEBmz2E5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718249320; c=relaxed/simple; bh=n/PPgK5K0GotzQ/uPPwNsR7mfn1H3/0FJcaWtmGAKW8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=i/By53c07NjQtFv6vgWCSvWbki2AbbEGQwWezT6vBat4qHGgWlcsv8DYuq9NunNNOpy5VLyZUVbdIJXbDbV5In18zAmVo+TGrMAP8rM5EhOAC1iWyc6WKY3nwM3pFViVwGOGoKSyjRHOiR/6sKhhAiRlquyYVVJdKsahb5dqZqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f175.google.com with SMTP id 71dfb90a1353d-4ed127d7c3dso150236e0c.1 for ; Wed, 12 Jun 2024 20:28:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718249318; x=1718854118; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1lhNM4y2L46tcjO0HaVOmUt/V/J9/oSem/zD16s3nQU=; b=li666nURRBlB7GwHtqEJ4oS/3uXF/nkXGVy+luWqR+QOj0L+KGRSx6x7lXHyVkIV/P RFaUmaR1RqRAHB+s706DnExpFhunDVBXizq+uCaAL/yZLITD8KjQ7m3+n0dVW7KmZyIQ zA9EIcU0BVPlhXxSBQ/Fhy71LXhPDPRutLyQ72ANpyezrv7X0qumlYUVyO3ZPVuoHnmT uZb4/QgzCp52EK1/en+FN3Y7DMDXgco1M95IZHkmf8K2EwCNYK/66YiHXYIAsXtTctUW FxlTxVRwWLrej6uIFLQDgkdcuRkNxcgkMWvCR5qJe1chFmfaA8EaZkdX8e2WNl+dTVga lQaw== X-Forwarded-Encrypted: i=1; AJvYcCXIKSfUBEhHgFJFES3A7wvBNcq7h1FU5B3uVhiVGXFwvl3TQxzZ30HNwW2ZI7jDEMuz/01rgfooajf+DOHPhAdClLH5BpgRcC+rv9bQ X-Gm-Message-State: AOJu0YxuZYc/XUs0+ussNIdCwdG4tMibLRMYMXrGjbtbqZAU224KdrMF xzP+txNF3Olk6SE+gNmKs7X+nKKuSOGNLRP/aA7zfDdJImbjwvy/MA+zLMHfAU3GAlTe4ZSvAPM +m8w7DHC/Fjvu0G4AmSAzuD47RTk= X-Received: by 2002:a05:6122:124e:b0:4da:ced8:b09a with SMTP id 71dfb90a1353d-4ed07720855mr3363389e0c.0.1718249318101; Wed, 12 Jun 2024 20:28:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240612081216.1319089-1-zhai.he@nxp.com> <20240612114748.bf5983b50634f23d674bc749@linux-foundation.org> In-Reply-To: From: Barry Song Date: Thu, 13 Jun 2024 15:28:26 +1200 Message-ID: Subject: Re: [EXT] Re: [PATCH v2] Supports to use the default CMA when the device-specified CMA memory is not enough. To: Zhai He Cc: Andrew Morton , "sboyd@kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Zhipeng Wang , Jindong Yue , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 13, 2024 at 2:34=E2=80=AFPM Zhai He wrote: > > > -----Original Message----- > > From: Barry Song > > Sent: Thursday, June 13, 2024 5:37 AM > > To: Andrew Morton > > Cc: Zhai He ; sboyd@kernel.org; linux-mm@kvack.org; > > linux-kernel@vger.kernel.org; stable@vger.kernel.org; Zhipeng Wang > > ; Jindong Yue ; Christoph > > Hellwig > > Subject: [EXT] Re: [PATCH v2] Supports to use the default CMA when the > > device-specified CMA memory is not enough. > > > > Caution: This is an external email. Please take care when clicking link= s or > > opening attachments. When in doubt, report the message using the 'Repor= t this > > email' button > > > > > > On Thu, Jun 13, 2024 at 6:47=E2=80=AFAM Andrew Morton > > wrote: > > > > > > On Wed, 12 Jun 2024 16:12:16 +0800 "zhai.he" wrote: > > > > > > > From: He Zhai > > > > > > (cc Barry & Christoph) > > > > > > What was your reason for adding cc:stable to the email headers? Does > > > this address some serious problem? If so, please fully describe that > > > problem. > > > > > > > In the current code logic, if the device-specified CMA memory > > > > allocation fails, memory will not be allocated from the default CMA= area. > > > > This patch will use the default cma region when the device's > > > > specified CMA is not enough. > > > > > > > > In addition, the log level of allocation failure is changed to debu= g. > > > > Because these logs will be printed when memory allocation from the > > > > device specified CMA fails, but if the allocation fails, it will be > > > > allocated from the default cma area. It can easily mislead develope= rs' > > > > judgment. > > > > I am not convinced that this patch is correct. If device-specific CMA i= s too small, > > why not increase it in the device tree? Conversely, if the default CMA = size is too > > large, why not reduce it via the cmdline? CMA offers all kinds of flex= ible > > configuration options based on users=E2=80=99 needs. > > > > One significant benefit of device-specific CMA is that it helps decreas= e > > fragmentation in the common CMA pool. While many devices allocate memor= y > > from the same pool, they have different memory requirements in terms of= sizes > > and alignments. Occasions of memory allocation and release can lead to > > situations where the CMA pool has enough free space, yet someone fails = to > > obtain contiguous memory from it. > > > > This patch entirely negates the advantage we gain from device-specific = CMA. > > My point is that instead of modifying the core code, please consider co= rrecting > > your device tree or cmdline configurations. > > > Because we enabled secure heap to support widevine DRM, and secure heap r= equires security configuration, its starting > address cannot be specified arbitrarily, which causes the default CMA to = be reduced. So we reduced the CMA, but in order > to avoid the impact of reducing the CMA, we used a multi-segment CMA and = gave one segment to the VPU. > > However, under our memory configuration, the device-specific CMA is not e= nough to support the VPU decoding high-resolution code streams, so this pat= ch is added so that the VPU can work properly. > Thanks. I don=E2=80=99t quite understand what you are saying. Why can=E2=80=99t you= increase VPU=E2=80=99s CMA size? It seems you mean that only in some corner cases do you need a large CMA, but most of the time, you don=E2=80=99t need it to be this big? So you have to "borr= ow" memory from the default CMA. but why not move that portion from the default CMA to your VPU=E2=80=99s CMA? Thanks Barry