Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10828877ybi; Thu, 25 Jul 2019 05:52:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9lhTh1g3S3ifpB+ksceYwzMAs+cyZaeChKmSQJVesBymOKahFvZKX4T+6TM4/xjhhz6Ob X-Received: by 2002:a5d:8497:: with SMTP id t23mr56354558iom.298.1564059121672; Thu, 25 Jul 2019 05:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564059121; cv=none; d=google.com; s=arc-20160816; b=p/qqGlx2GtrDGhSVhIxQ7NqKMNJyV+6buiS/osfPqtpbzgxiK8nVES6dcmkBDCARVf VaY7OSmj/wyTasIcrNwb1XxPKKpiH1PJoJFmS65ElYLZICsnD3feSQzv6mk3HWjbFdU5 o7Cqcj5IOfEPKm9ebikNFQ6ddIDBNOtlwc4wgPr6rvLJHH+qOMbnGxTQ4axYjeg7D0NW ShYOa67nyGhJqe5U6NZ4MK/lgyxGORa4SVpu8iieWgAuED2ZUiKeOi0Kp5t8t1B3SroI GeJElou46vRkUBp4ng7hZ2HaeY1Z/otKtkkj6Qnn3KlAe6pJcmm7EeF4nBSZCgmDhaHM /6pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=HbzEkwwAnwuWE5b5d6k9i8CVnxaD0oKHoYQVN8wgz2s=; b=QD+IwAZEb5F2sLZWpAOrTiVqR6qogEbVlfn32qbE9+Te3oS1akkB0bMOegohsoZgek As71GMZMJR31Ct66tH29vAZ2PZMiIxqFh7zKuDkIXHVQBjw0dzAcbLHkOLbso+C3yJ75 aLLn5i4EXuNFdHhM0X1lLdLVKKv4sIVL4NkYYjJggd7ZxeJeLxeFfnEty0XgFMEwBUEN aZLmLW9jZhnUHnT0XPHcF5UiPV6RQKHPljmXeGiMt0nzgyovTnjK8N67FvTxP7LimAm5 W+07jyDmw17ZePpLplfjxwf1Tk49J10c2sXdgcdcCVVbAg9vzHfnbg8M8YzosfsXVyEb uh8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si61180888ioo.132.2019.07.25.05.51.49; Thu, 25 Jul 2019 05:52:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390377AbfGYJVN convert rfc822-to-8bit (ORCPT + 99 others); Thu, 25 Jul 2019 05:21:13 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:45139 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389529AbfGYJVM (ORCPT ); Thu, 25 Jul 2019 05:21:12 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-235-scnLaRCdNWKuzfuwzi4QFQ-1; Thu, 25 Jul 2019 10:21:09 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 25 Jul 2019 10:21:08 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 25 Jul 2019 10:21:08 +0100 From: David Laight To: 'Jian-Hong Pan' , Yan-Hsuan Chuang , Kalle Valo , "David S . Miller" CC: "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux@endlessm.com" , "stable@vger.kernel.org" Subject: RE: [PATCH] rtw88: pci: Use general byte arrays as the elements of RX ring Thread-Topic: [PATCH] rtw88: pci: Use general byte arrays as the elements of RX ring Thread-Index: AQHVQsDFH4BG56wpwU66J+Fzxhx3XabbDGOQ Date: Thu, 25 Jul 2019 09:21:08 +0000 Message-ID: <06d713fff7434dfb9ccab32c2e2112e2@AcuMS.aculab.com> References: <20190725080925.6575-1-jian-hong@endlessm.com> In-Reply-To: <20190725080925.6575-1-jian-hong@endlessm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: scnLaRCdNWKuzfuwzi4QFQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jian-Hong Pan > Sent: 25 July 2019 09:09 > Each skb as the element in RX ring was expected with sized buffer 8216 > (RTK_PCI_RX_BUF_SIZE) bytes. However, the skb buffer's true size is > 16640 bytes for alignment after allocated, x86_64 for example. And, the > difference will be enlarged 512 times (RTK_MAX_RX_DESC_NUM). > To prevent that much wasted memory, this patch follows David's > suggestion [1] and uses general buffer arrays, instead of skbs as the > elements in RX ring. ... > for (i = 0; i < len; i++) { > - skb = dev_alloc_skb(buf_sz); > - if (!skb) { > + buf = devm_kzalloc(rtwdev->dev, buf_sz, GFP_ATOMIC); You should do this allocation somewhere than can sleep. So you don't need GFP_ATOMIC, making the allocate (and dma map) much less likely to fail. If they do fail using a smaller ring might be better than failing completely. I suspect that buf_sz gets rounded up somewhat. Also you almost certainly want 'buf' to be cache-line aligned. I don't think devm_kzalloc() guarantees that at all. While allocating all 512 buffers in one block (just over 4MB) is probably not a good idea, you may need to allocated (and dma map) then in groups. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)