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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86C7AC11F67 for ; Tue, 29 Jun 2021 16:01:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 13F1C61DC0 for ; Tue, 29 Jun 2021 16:01:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13F1C61DC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 492FE8D0153; Tue, 29 Jun 2021 12:01:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41C298D00F0; Tue, 29 Jun 2021 12:01:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26EC48D0153; Tue, 29 Jun 2021 12:01:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id EE19E8D00F0 for ; Tue, 29 Jun 2021 12:01:17 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6CCF1814B0CA for ; Tue, 29 Jun 2021 16:01:17 +0000 (UTC) X-FDA: 78307225794.37.2BE44EA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 555BF18B4 for ; Tue, 29 Jun 2021 16:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624982476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q3iRhbclAGpXROLJyUpX6Pw21XMZ1Ti2hB2Ivbm6GwU=; b=boMp//QY2fJWU5Q4RU9TKtzVCJzFvPFdEaHZsnF1aSTd/iiJVaGH2fzJ/+s1Fj1FVgRAfp SqVnSOPs1fyRl7h5seEsskQqlojwltviwv09i2giUWDPlgMJjeE50Q785GDmoUdEnksfc4 7aGZeRM5Mu1jVo7h2Tj/lHCttm/q7Xg= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-Un-qOU3zMoi7tZxGp2AgHQ-1; Tue, 29 Jun 2021 12:01:15 -0400 X-MC-Unique: Un-qOU3zMoi7tZxGp2AgHQ-1 Received: by mail-ej1-f69.google.com with SMTP id de48-20020a1709069bf0b029048ae3ebecabso5878387ejc.16 for ; Tue, 29 Jun 2021 09:01:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Q3iRhbclAGpXROLJyUpX6Pw21XMZ1Ti2hB2Ivbm6GwU=; b=XA/4/UzwMAHo0Cg2N2z4rE9rjNKhyEaFcEj1fNyBtSD2LCleKM1AxTQ5iVxbVzYqHC cPxYLGBbvdj1mZN71gh/HLMUH5RYZuEBYT86OyPgc6aCKwHBxEZzSv+v0SpGO7lnHgFr KayFrfEngge33vHj7sIbk3FdU/jsK1jpbahImPFUzHMiSHl0vO0nvAT6oIMbo28FW4t+ sOTr4pSfM8sXWEQrOMVPzLuojChp28HOSkIe1inutb2IDqdOZVnlwfmBbhSbmGyq7/T+ qrGo21OHAtC16jwZiUp14Vk6xfCU2/jQ09NBQTwTeMczDd16Od9X3w7pi7Du4Te8IIMw A0AQ== X-Gm-Message-State: AOAM533xr8gYRo7Ll5Y2/MT7iLqfqwk7PwL2IqJpUxmBQAvmL4hj1kuo oILSlQnGL2yTnc/bp5dKPeNHz5/k9ehCqserOQkHJ80O3F+wR6KWrqPcyqXLLFoT1yUte/0OKGm 3nW0Ccm0wFAw= X-Received: by 2002:aa7:d592:: with SMTP id r18mr6878657edq.269.1624982474220; Tue, 29 Jun 2021 09:01:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzHHBh/dOOBuzH+iLhxo7Ei4q2Sb0V9xqbsaUrEKcAK8Ljsc42TzCSKRVhFES5NkxpomEUOQ== X-Received: by 2002:aa7:d592:: with SMTP id r18mr6878634edq.269.1624982474034; Tue, 29 Jun 2021 09:01:14 -0700 (PDT) Received: from [192.168.42.238] (3-14-107-185.static.kviknet.dk. [185.107.14.3]) by smtp.gmail.com with ESMTPSA id v5sm11415632edt.55.2021.06.29.09.01.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 09:01:13 -0700 (PDT) Subject: Re: [PATCH v3] mm/page_alloc: Further fix __alloc_pages_bulk() return value To: Chuck Lever , mgorman@techsingularity.net Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org, brouer@redhat.com References: <162497449506.16614.7781489905877008435.stgit@klimt.1015granger.net> From: Jesper Dangaard Brouer Message-ID: Date: Tue, 29 Jun 2021 18:01:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <162497449506.16614.7781489905877008435.stgit@klimt.1015granger.net> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 555BF18B4 X-Stat-Signature: za84pw4kq85qei3nadkwtn9ahhhqie9g Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="boMp//QY"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf22.hostedemail.com: domain of jbrouer@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=jbrouer@redhat.com X-HE-Tag: 1624982477-469193 Content-Transfer-Encoding: quoted-printable 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 29/06/2021 15.48, Chuck Lever wrote: > The call site in __page_pool_alloc_pages_slow() also seems to be > confused on this matter. It should be attended to by someone who > is familiar with that code. I don't think we need a fix for __page_pool_alloc_pages_slow(), as the=20 array is guaranteed to be empty. But a fix would look like this: diff --git a/net/core/page_pool.c b/net/core/page_pool.c index c137ce308c27..1b04538a3da3 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -245,22 +245,23 @@ static struct page=20 *__page_pool_alloc_pages_slow(struct page_pool *pool, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(pp_order)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 return __page_pool_alloc_page_order(pool, gfp); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Unnecessary as alloc cache= is empty, but guarantees zero=20 count */ -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(pool->alloc.count > 0)= ) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(pool->alloc.count > 0)= )=C2=A0=C2=A0 // ^^^^^^^^^^^^^^^^^^^^^^ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 return pool->alloc.cache[--pool->alloc.count]; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Mark empty alloc.cache slo= ts "empty" for=20 alloc_pages_bulk_array */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 memset(&pool->alloc.cache, 0,= sizeof(void *) * bulk); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* bulk API ret value also count ex= isting pages, but array is=20 empty */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_pages =3D alloc_pages_bulk= _array(gfp, bulk, pool->alloc.cache); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(!nr_pages)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 return NULL; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Pages have been filled int= o alloc.cache array, but count is=20 zero and =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * page element have not= been (possibly) DMA mapped. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (i =3D 0; i < nr_pages; i++) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (i =3D pool->alloc.count; i < n= r_pages; i++) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 page =3D pool->alloc.cache[i]; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 if ((pp_flags & PP_FLAG_DMA_MAP) && =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unlikely(!page_pool_dma_map(po= ol, page))) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 put_pa= ge(page);