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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38844C433F5 for ; Tue, 5 Oct 2021 08:46:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD50E6120C for ; Tue, 5 Oct 2021 08:46:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CD50E6120C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5A01B6B006C; Tue, 5 Oct 2021 04:46:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54FCF6B0071; Tue, 5 Oct 2021 04:46:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43ED3900002; Tue, 5 Oct 2021 04:46:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 34EAE6B006C for ; Tue, 5 Oct 2021 04:46:02 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B115A8249980 for ; Tue, 5 Oct 2021 08:46:01 +0000 (UTC) X-FDA: 78661751322.20.26BAB59 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf10.hostedemail.com (Postfix) with ESMTP id 40F9D60020AD for ; Tue, 5 Oct 2021 08:46:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E058020272; Tue, 5 Oct 2021 08:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1633423559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ExidNuWCqnGf0/HJrIEctui2gYVjZ4NbIpRJWFCI2Ns=; b=G2H3j7aIGcNz3ZWnQywfH18Mj7c4BPPgP6FRHA3/POFjoE9msPfEhr/FR0wPv0NDZqlUbr 0cKUAH9ZcbBwP1XgtaNQg8b+mmiS/KhpYtuynnFeqFg+NevZT6qnGUEtGheCl+2tpH9BWd qAvh7CLwe+eHqXDjSYUthh3oBt1a0C0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1633423559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ExidNuWCqnGf0/HJrIEctui2gYVjZ4NbIpRJWFCI2Ns=; b=6An5bkniBrbnJyKoLShgnPmmt3vlLrcqP1zbiVqFUIkUQWnvef8kZ+qWsBwpKrOskSI9Mw xRSFWPkPnSiYq7DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4773C1342A; Tue, 5 Oct 2021 08:45:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RSmoDscQXGH8bAAAMHmgww (envelope-from ); Tue, 05 Oct 2021 08:45:59 +0000 Date: Tue, 5 Oct 2021 10:45:57 +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: <20211005084557.GB20412@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) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 40F9D60020AD X-Stat-Signature: p8nhm146bqkjic6c77qk1hf4hkxjisrt Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=G2H3j7aI; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=6An5bkni; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf10.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=osalvador@suse.de X-HE-Tag: 1633423561-695684 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 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; > - After this patch, the timing of printing the debug statement changes as we back off earlier. You might want to point that out in the changelog in case someone wonders why. -- Oscar Salvador SUSE Labs