Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2212067ybi; Thu, 4 Jul 2019 06:58:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTrlefskW2UzQJikCux/AaLSuKp6+8HJpiTzS4XChEy6IZ2H4tobpD5ZBFoTh6G3aXPXDc X-Received: by 2002:a17:90a:23a4:: with SMTP id g33mr20483333pje.115.1562248738987; Thu, 04 Jul 2019 06:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562248738; cv=none; d=google.com; s=arc-20160816; b=lltNAwEoyuxFccbv513ylvP5IZjV7TCYp/bLKoBb61QwTlX7zf0pA42Y3IzosFXcDI oZiqvnockhH54ZBsddJSrogo5fSs3VhXK7cDJvW79Qh7A0qD90Q9BG+e7szB2Wby/fYS lmaSjfxERpahJuYTpG6xUEYK9GJbpekztEYisVroXgcHYk1erFe8sNS+urH/2L4FgDTF RzU3p82u73Y4D8zJV7UlIW0BZa4+3yO3oXA6+N6KY/rLj1Itbuxjrhd9yjy7lSmeaDZ7 Vu/B6L0GXKJhRjs00ym9B2lCH9hPH3djDVndlTUPQXMRlrylt5V8M/OO0nKtxFts1Tma P3EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/RLAY7zRxS6FP4wLWk1a+mxOsYYdecRt8hhGgB9GW4M=; b=iY0NWWDPjOecW54DyMWPPqKD60Xr5EkFVpICwcg6EiA4BJMEPOWIy2VVn714fUJvsK Y6RrErwfQYWa0y7O1P5/PjPveTILbPy+uQLO5vEVQ1JeFTs6Cqb7NE2rwh9CfGMvGUvG 5DFro89DURBezFr13IfxOz9fejn5w1P1q1U/onWJhx31atLxgydAXA19m2MyLz+HsxOC 4DJtx+bMg6tZjjy61p1iEt8PaqUqXmiX//khJBEzsNtvCmj/jG7oH3KRyu7ZLefO7Y96 Bg0a2AxaB9a/ZpU79MK2oxEKor7yrQuKez3n3p3/JyGzpibH+Yluadfx/ppsVeniy5+4 OZvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="nf1/g8o8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 n8si5826497pfa.223.2019.07.04.06.58.43; Thu, 04 Jul 2019 06:58:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="nf1/g8o8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbfGDN6H (ORCPT + 99 others); Thu, 4 Jul 2019 09:58:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40750 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbfGDN6G (ORCPT ); Thu, 4 Jul 2019 09:58:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/RLAY7zRxS6FP4wLWk1a+mxOsYYdecRt8hhGgB9GW4M=; b=nf1/g8o8E65eZqwz1hsFwCPcU MBhwLZirPk/vxTpaggeMfdAROG8JpB00Rj6iiyRqEOQApcd1+J/mLDVIXT4EV/PuEYg2phrQHywIQ 9bztNfHZywQ2ABH4jnMjnJ8vuukFS0jb4MSlY0QCLjMraK2KjUDTM7z0J5ilmg8poMPmJ9SXKwzmh iQKIP77O6i2PNUBBSwUR7QvppXdrJTr4lRMqEVBgd/OaM7fy/QdHnSAcGafKBFvF1TOK9I+R0vvId b2s9evEN1sD+tCOKAqNbdSzQHl+EVFwGBqM6BgNQzCRhbVR0Zu9hKIPbPsCXsgrGUNKfGuwBO7sEe xNz/Er2kQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hj2FQ-0002ZJ-Vt; Thu, 04 Jul 2019 13:58:04 +0000 Date: Thu, 4 Jul 2019 06:58:04 -0700 From: Matthew Wilcox To: Boaz Harrosh Cc: Dan Williams , linux-fsdevel , Jan Kara , stable , Robert Barror , Seema Pandit , linux-nvdimm , Linux Kernel Mailing List Subject: Re: [PATCH] dax: Fix missed PMD wakeups Message-ID: <20190704135804.GL1729@bombadil.infradead.org> References: <156213869409.3910140.7715747316991468148.stgit@dwillia2-desk3.amr.corp.intel.com> <20190703121743.GH1729@bombadil.infradead.org> <20190703195302.GJ1729@bombadil.infradead.org> <20190704032728.GK1729@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 04, 2019 at 04:00:00PM +0300, Boaz Harrosh wrote: > On 04/07/2019 06:27, Matthew Wilcox wrote: > > On Wed, Jul 03, 2019 at 02:28:41PM -0700, Dan Williams wrote: > >>> +#ifdef CONFIG_XARRAY_MULTI > >>> + unsigned int sibs = xas->xa_sibs; > >>> + > >>> + while (sibs) { > >>> + order++; > >>> + sibs /= 2; > >>> + } > >> > >> Use ilog2() here? > > > > Thought about it. sibs is never going to be more than 31, so I don't > > know that it's worth eliminating 5 add/shift pairs in favour of whatever > > the ilog2 instruction is on a given CPU. In practice, on x86, sibs is > > going to be either 0 (PTEs) or 7 (PMDs). We could also avoid even having > > this function by passing PMD_ORDER or PTE_ORDER into get_unlocked_entry(). > > > > It's probably never going to be noticable in this scenario because it's > > the very last thing checked before we put ourselves on a waitqueue and > > go to sleep. > > Matthew you must be kidding an ilog2 in binary is zero clocks > (Return the highest bit or something like that) You might want to actually check the documentation instead of just making shit up. https://www.agner.org/optimize/instruction_tables.pdf I think in this instance what we want is BSR (aka ffz) since the input is going to be one of 0, 1, 3, 7, 15 or 31 (and we want 0, 1, 2, 3, 4, 5 as results). > In any way. It took me 5 minutes to understand what you are doing > here. And I only fully got it when Dan gave his comment. So please for > the sake of stupid guys like me could you please make it ilog2() so > to make it easier to understand? > (And please don't do the compiler's job. If in some arch the loop > is the fastest let the compiler decide?) The compiler doesn't know the range of 'sibs'. Unless we do the profile-feedback thing.