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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CACC0C4332F for ; Thu, 15 Dec 2022 01:06:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52EC48E0006; Wed, 14 Dec 2022 20:06:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DE568E0002; Wed, 14 Dec 2022 20:06:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A61C8E0006; Wed, 14 Dec 2022 20:06:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 29EF28E0002 for ; Wed, 14 Dec 2022 20:06:16 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BE358AB623 for ; Thu, 15 Dec 2022 01:06:15 +0000 (UTC) X-FDA: 80242749510.29.A375341 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 297C81C0014 for ; Thu, 15 Dec 2022 01:06:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AYdGixrk; spf=pass (imf21.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671066374; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6SX5ZzHEybWQrQxJLxiT9zanQMGhd2Al6flIE5ogWzk=; b=0YTJShrzskAoqBw7TyZtyaQQCExZzhxGXStvHn8s+wRl5XS5H6qGcyNbuXcS3llC6/r1zz rxJ/Ic6PxXOuZOdm6x8McIYWxU/iCTesHR5dC7LvnEhblbxcVhlK1pKCqIUIEaGeDd+REz 8WpL6LowgviF13Z/khkC0YaYPFAGKzU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AYdGixrk; spf=pass (imf21.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671066374; a=rsa-sha256; cv=none; b=V/qyp33JhIXohZu7cH15731yftuYUCIFhB3Bp9QznWPJytETtrAQ+w/oJcnF59YoI9i6TR SdPu9dMYE0b2UUWj5DtTtG7V+/7qE4fCoYsnE98A98Zg8Ut6Oota/b+m5y9qWiighARn9s gVUc3M8qL8sLhSTx9yyX7VicMAidUa8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671066372; 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: in-reply-to:in-reply-to:references:references; bh=6SX5ZzHEybWQrQxJLxiT9zanQMGhd2Al6flIE5ogWzk=; b=AYdGixrkciaWbvzT+nFhWF4e/hVcNmE1JbFxzULKjovb9vIvA4rQXdyPtvsXcH01jrv5sc jxAtrL9CJQtaEnQdI9XlOHkVcJYWs32k10hyqwTLtWUTllPuy1E0cYiSgTwHNXFCxWosXT BN9KkQe1DhxpaZMvTsxNo08g6OCxQMg= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-271-W0M7bmrvPfWmfGNfXH-1nA-1; Wed, 14 Dec 2022 20:06:11 -0500 X-MC-Unique: W0M7bmrvPfWmfGNfXH-1nA-1 Received: by mail-yb1-f200.google.com with SMTP id n197-20020a25d6ce000000b00702558fba96so1954444ybg.0 for ; Wed, 14 Dec 2022 17:06:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6SX5ZzHEybWQrQxJLxiT9zanQMGhd2Al6flIE5ogWzk=; b=7uaRExHVVth+DqXB11y6e2+eRxk/apcPi7ClLUDxh++T9biFW3F59LqyDB66Rqr63Y KC+wZwOpHum7DYc2l4Mwi1qOWtxSA77yhYLPub0wpGdjKtRqART+/JoyFwizGVUhjvSN zrOMkfmxSkHT8+wMJ7zEG6zzIQE11Oc4cjhL8x26QkUXUqLxJA9h/YSYJhs/EtnA0jy+ NXvypJlPOio7wVK2tuYlpwTzsyD5JJTpr0by/CNECsCvIBIbb5wS0T5paZQAKMOHR2kR tjCJQERFr/pnk1ETwutSs14xFoex71hjri1WdsY4EQ1AvBzKcZAY6M2ZDROx0g4xWeB8 vAZg== X-Gm-Message-State: ANoB5pnjwsN+5/VjV9VapMq7eIcA9i+pj70UhfGJ641CIQkQv7q4+Gdu 7g+o+FCiH3WfWyYZutPw++akVLdOuc/CaJJW/LtNG2H6bsEgOtrB1U/YRwLzdJkHgwDj7FRpvQT R3l6ylHA+U3whBqrYSzUHxRMB5s4= X-Received: by 2002:a25:4008:0:b0:728:37a1:b4ac with SMTP id n8-20020a254008000000b0072837a1b4acmr1236359yba.63.1671066370844; Wed, 14 Dec 2022 17:06:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iReGa+vX68Fe0jrwCwf6H644+1hYm3UmS0ulsI8BPMFqUtrOd3jIFloeXiXXxYGe1/uo5NAtxXVx1aNp1CWo= X-Received: by 2002:a25:4008:0:b0:728:37a1:b4ac with SMTP id n8-20020a254008000000b0072837a1b4acmr1236354yba.63.1671066370587; Wed, 14 Dec 2022 17:06:10 -0800 (PST) MIME-Version: 1.0 References: <20221213234505.173468-1-npache@redhat.com> In-Reply-To: From: Nico Pache Date: Wed, 14 Dec 2022 18:05:44 -0700 Message-ID: Subject: Re: [RFC V2] mm: add the zero case to page[1].compound_nr in set_compound_order To: Sidhartha Kumar Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev, akpm@linux-foundation.org, willy@infradead.org, gerald.schaefer@linux.ibm.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: yxyged6omwr79tpy3he6zfbja6ugq51n X-Rspam-User: X-Rspamd-Queue-Id: 297C81C0014 X-Rspamd-Server: rspam06 X-HE-Tag: 1671066373-604913 X-HE-Meta: U2FsdGVkX1+mRWfnOGe+M05pJHsD1hLzC12UbA9vSOylBlwn3gK5OwKLw1q+h9D/kHBfgW8SFc1C9HRlJK4CJGhmTLtddV9n+cuBubXp6nfELkZpRGiTeRiJdGPFqUyyMDXbYZ8L4bhQ+6FR7lyw8xWOGEw9u/y6AwfrlUDp9L1TTQ8sBTl6uckuc/bh2u9xXoVoMKtnAOs/rqm9YEhMpL0GFfbuiu+nU9IyYI578qZytSKHw0V96Fh3zkzLHeUiC4AO4xLFvsYJlPlrhkiOhGWpH971sisvOLh1jOlbCkTN3v5FSD0WtyM0fELlTdkpNg5FReIH0IIrGAkAsoF9Bnmz9YhqWu0CYruF0kLLRKkrZiLHSxiMRD/egEvDUbYrZgVrH1Dp/Kkc6CWmd6ZNMo/RZRx3JvMcLktl91GfWe4ABJ/c6BL1qitK0khh7gtt8Qm1U7qNq1raRgQNwgRHzZYCPyQ7fGTG/t3T4TyyAY+xgRZFdkieJlYJjVP2zr1H/pEFbznivXA4XApUTVWro+Mmk3Rsl1au7Oa2udRSZC4w2toNdPEVPtzUStwrDZ4DxIJsJzAKZgOd+Z5SJqXFZ9lR67wAx2StU4TGQ7slZ+yE6eR4D9SH3xrmo2plefzUeDrHcpYUJ2sX1gJqwpi1sk9hHP30vgknSdvrXDgit8Jy3FPXK1bZwRkXrdwA8So1pQMtiigLQ49iEp8elM8120I1X9r2cTi7i2ZTggo2HCCBRqAOwQzjk4V4gZhG4bM/yyxILPZhwIzMhqVNytWHrVuqn/Q4MReRthfvyMjmrbK53R73Dm+4D72pbOW1Q/T0OS7sms6sQeZck5kfOtqTcZneimKdrdRQYolRvWd6goYDxTrxgQXNwjBO/CKufPDaGBD2fcJIpt9dvoofFCd0AEAU27b+BX8vk7XBuTRUwbCM5kTOh6yGps/YLg19q2cZ9PKSpj7Y2Ew41S6EYGH h2Mmwsm+ ufhF3y0hx5ernt9sUkDcqkrgbqTbE/cez6yR9X3hhU7FoILLNQJMKWe0mzKJxtoollDA+CeBw310BGWo= 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 Tue, Dec 13, 2022 at 11:38 PM Sidhartha Kumar wrote: > > On 12/13/22 5:02 PM, Mike Kravetz wrote: > > On 12/13/22 17:27, Nico Pache wrote: > >> According to the document linked the following approach is even faster > >> than the one I used due to CPU parallelization: > > > > I do not think we are very concerned with speed here. This routine is being > > called in the creation of compound pages, and in the case of hugetlb the > > tear down of gigantic pages. In general, creation and tear down of gigantic > > pages happens infrequently. Usually only at system/application startup and > > system/application shutdown. > > > Hi Nico, > > I wrote a bpftrace script to track the time spent in > __prep_compound_gigantic_folio both with and without the branch in > folio_set_order() and resulting histogram was the same for both > versions. This is probably because the for loop through every base page > has a much higher overhead than the singular call to folio_set_order(). > I am not sure what the performance difference for THP would be. Hi Sidhartha, Ok great! We may want to proactively implement a branchless version so once/if THP comes around to utilizing this we won't see a regression. Furthermore, Waiman brought up a good point off the list: This bitmath is needlessly complex and can be achieved with page[1].compound_nr = (1U << order) & ~1U; Tested: order 0 output : 0 order 1 output : 2 order 2 output : 4 order 3 output : 8 order 4 output : 16 order 5 output : 32 order 6 output : 64 order 7 output : 128 order 8 output : 256 order 9 output : 512 order 10 output : 1024 > Below is the script. > Thanks, > Sidhartha Kumar Thanks for the script!! Cheers, -- Nico > k:__prep_compound_gigantic_folio > { > @prep_start[pid] = nsecs; > } > > kr:__prep_compound_gigantic_folio > { > @prep_nsecs = hist((nsecs - @prep_start[pid])); > delete(@prep_start[pid]); > }