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 599AEC11F69 for ; Wed, 30 Jun 2021 11:22:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E57C7617ED for ; Wed, 30 Jun 2021 11:22:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E57C7617ED 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 613C48D019F; Wed, 30 Jun 2021 07:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EA938D017A; Wed, 30 Jun 2021 07:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4647E8D019F; Wed, 30 Jun 2021 07:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 236648D017A for ; Wed, 30 Jun 2021 07:22:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 01B04231C8 for ; Wed, 30 Jun 2021 11:22:30 +0000 (UTC) X-FDA: 78310152060.04.B6EE9B9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 941CA500034C for ; Wed, 30 Jun 2021 11:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625052149; 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=hZe3HRwjGbdUS4a+UHy4KVxNJVUaIIhLxmWrSO/7m/4=; b=avhVoNmfQTlLfKc8UoFfCfCdc5a9CT2ro/SxiHqCKF3AIakEOSdVET2OTd2V7gxjNgA51E bBsU/9b40bFmnVZz969+a7w7DPCIvC/N7D1+V0l/I2jcPoNFrM3kyYItp+URurbBrDRsoX IiaEhEuEXJcIUrabj2wBgAeNrA9GtRg= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-3uUT6ZukN0iIWgVIgbQTtQ-1; Wed, 30 Jun 2021 07:22:27 -0400 X-MC-Unique: 3uUT6ZukN0iIWgVIgbQTtQ-1 Received: by mail-ej1-f71.google.com with SMTP id lu1-20020a170906fac1b02904aa7372ec41so634797ejb.23 for ; Wed, 30 Jun 2021 04:22:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=hZe3HRwjGbdUS4a+UHy4KVxNJVUaIIhLxmWrSO/7m/4=; b=CxI4kxfhk+KjVO3uUYg2RugcsAvjY1IJK2fUpPlNpNnXu9Ob+LDwwtNXzXSKsMTe4k zfJy4s3kUzHdjvyskDREDlsb7iYiix7HyXuXQdLnpMOIaEtqJkULEnu/nCvLRUuFgPCI 6JpLJ6rdayEQZIBd/Op5Qqjq4Hgpkv7chYOpZjWYU9p0alPHgsEDI2W2vlcPjxhvbRdK nudl6/PIOhBW3hQK7hkQQgmc/plLKtzoNtfOHXJEqhtxSR7ZUs9FIQpQVmZ/sVa6vq33 8zQVIY8EGgJdl4Xjepm6OQjXLoWHaybEjwfqOzXORrZttUfjBcaFRJkId48Qp50tBKD9 mjsg== X-Gm-Message-State: AOAM533pr9TvRPtbH80ytONQH0MRIZEyYV20B/tR2DjYNMiegtdDcvqa /mSjigv1Kni8dYIzE5GINhJ0wKzpYyjjkkfHIzOrCcYCbpnAErZQMDNwR66FB+uDjlEW/pL0uen 2nNFVpupHO9A= X-Received: by 2002:aa7:cc0c:: with SMTP id q12mr6424953edt.90.1625052146563; Wed, 30 Jun 2021 04:22:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl846YvgPZS/i3m2UiD4wApXBXBXOk7WDMlmWd/jD2eoxyN84be9yTzU49FOsX5kva58d6gA== X-Received: by 2002:aa7:cc0c:: with SMTP id q12mr6424939edt.90.1625052146336; Wed, 30 Jun 2021 04:22:26 -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 b24sm9431321ejl.61.2021.06.30.04.22.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Jun 2021 04:22:25 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Subject: Re: [PATCH v3] mm/page_alloc: Further fix __alloc_pages_bulk() return value To: Mel Gorman Cc: Chuck Lever , linux-nfs@vger.kernel.org, linux-mm@kvack.org, brouer@redhat.com References: <162497449506.16614.7781489905877008435.stgit@klimt.1015granger.net> <20210630065855.GH3840@techsingularity.net> Message-ID: <543ef038-d50c-f035-bd9d-ae3140ca0e33@redhat.com> Date: Wed, 30 Jun 2021 13:22:24 +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: <20210630065855.GH3840@techsingularity.net> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=avhVoNmf; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of jbrouer@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=jbrouer@redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: snamxx4598z8mk478ie3tawqwe6pyqq7 X-Rspamd-Queue-Id: 941CA500034C X-HE-Tag: 1625052149-979983 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 30/06/2021 08.58, Mel Gorman wrote: > On Tue, Jun 29, 2021 at 06:01:12PM +0200, Jesper Dangaard Brouer wrote: >> 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= 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 >> *__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 ca= che is empty, but guarantees zero 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 = slots "empty" for 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= existing pages, but array is empty >> */ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nr_pages =3D alloc_pages_b= ulk_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 = into alloc.cache array, but count is 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 = < nr_pages; i++) { > That last part would break as the loop is updating pool->alloc_count. The last part "i =3D pool->alloc.count" probably is a bad idea. > Just setting pool->alloc_count =3D nr_pages would break if PP_FLAG_DMA_= MAP > was set and page_pool_dma_map failed. Right? Yes, this loop is calling page_pool_dma_map(), and if that fails we=20 don't advance pool->alloc_count. --Jesper