Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4381767pxb; Tue, 5 Oct 2021 01:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl6UOerji49fHIaHaQ1GKwokcRWZ5P+b+F3OU0P3dbZofB/huRBLo5cTpxb04JBgJZQm5L X-Received: by 2002:a17:902:b583:b0:13d:e495:187a with SMTP id a3-20020a170902b58300b0013de495187amr4183717pls.9.1633423477919; Tue, 05 Oct 2021 01:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633423477; cv=none; d=google.com; s=arc-20160816; b=nADHEGzfhQXdfHfF0VlHIaNA/Og/M/Ky4HRQPY9HW0TizmbBDS6o6KC0YNubyd02j8 So6amLUZsorsm0PgOfwLwkLwMGim14SN4z2bvFpy5o10KYGOj1OYIrul/m5dc9L2NFdm vkLjJsxRlf/eRlYa4WqpKqWWJFPpAXg8TjXnjDr+6rVKpTGH3YpdksrGxfknylb35uza GDQZhdUSQ6C9NLQIHHIgJwHc9Gv23XBe4JQDzGou7bhRSJBG9s2x7hN179zxm4NwUxCD HK+11uu2NkIV0Y39C66sfHtD3+8iwIKtM8j402IkZA1x2GX0v0oPey/cDQpN6HolvqfL y1eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=T9PtPSPWlNi+Kn+Cg4dAjQiM3CpBC8vpAF2PsRYxVW0=; b=cNvcPgg/qy3EQh82ightPYLOcrIh3TuO25V1bvkLI4wxARiXifbviLtrfc7Y0YAzhs OmEEzIe5NVhOybBLVcffDbr+4hdpYNp5pq6ZdTEPPwkGN+vSiOO27eIf3RN3iBUDL0UI 9WpEdB5YVzc0INx8dBOOZYm3QhoFYFG8kYA4IHax0SsGAz+AzsvZPL/S70qrBno9RyLu ws42BaDCLiYzn8ZsF1tmIdTFddvJen1ndaWQ7SQ3bW5/n1WuaWIfIpWOJGW5Ghq1/iCM lQSdV19OC5V11k8J/aEgRDjYsgsmIt5ixU+Pi5gSn08BEre7sWqlHDqf2D9RUKoGnl5e XEWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si20611266pll.317.2021.10.05.01.44.24; Tue, 05 Oct 2021 01:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbhJEIov (ORCPT + 99 others); Tue, 5 Oct 2021 04:44:51 -0400 Received: from 232.88.17.95.dynamic.jazztel.es ([95.17.88.232]:57110 "EHLO suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232974AbhJEIou (ORCPT ); Tue, 5 Oct 2021 04:44:50 -0400 X-Greylist: delayed 460 seconds by postgrey-1.27 at vger.kernel.org; Tue, 05 Oct 2021 04:44:50 EDT Received: by suse.de (Postfix, from userid 1000) id 92EAEA413; Tue, 5 Oct 2021 10:35:17 +0200 (CEST) Date: Tue, 5 Oct 2021 10:35:17 +0200 From: Oscar Salvador To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand , Michal Hocko , Zi Yan , Muchun Song , Naoya Horiguchi , David Rientjes , "Aneesh Kumar K . V" , Andrew Morton Subject: Re: [PATCH v3 2/5] mm/cma: add cma_pages_valid to determine if pages are in CMA Message-ID: <20211005083516.GA20090@linux> References: <20211001175210.45968-1-mike.kravetz@oracle.com> <20211001175210.45968-3-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001175210.45968-3-mike.kravetz@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 10:52:07AM -0700, Mike Kravetz wrote: > +bool cma_pages_valid(struct cma *cma, const struct page *pages, > + unsigned long count) > +{ > + unsigned long pfn; > + > + if (!cma || !pages) > + return false; > + > + pfn = page_to_pfn(pages); > + > + if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) > + return false; > + > + return true; > +} > + > /** > * cma_release() - release allocated pages > * @cma: Contiguous memory region for which the allocation is performed. > @@ -539,16 +555,13 @@ bool cma_release(struct cma *cma, const struct page *pages, > { > unsigned long pfn; > > - if (!cma || !pages) > + if (!cma_pages_valid(cma, pages, count)) > return false; > > pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count); > > pfn = page_to_pfn(pages); > > - if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) > - return false; > - Might be worth noting that after this change, the debug statement will not be printed as before. Now, we back off before firing it. You might want to point that out in the changelog in case someone wonders why. -- Oscar Salvador SUSE Labs