From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx112.postini.com [74.125.245.112]) by kanga.kvack.org (Postfix) with SMTP id 8AD096B0002 for ; Mon, 4 Mar 2013 06:52:58 -0500 (EST) Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Mar 2013 17:19:30 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id ACE9E3940055 for ; Mon, 4 Mar 2013 17:22:50 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r24Bqltu16122110 for ; Mon, 4 Mar 2013 17:22:47 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r24BqowB030245 for ; Mon, 4 Mar 2013 22:52:50 +1100 From: "Aneesh Kumar K.V" Subject: Re: [PATCH -V1 09/24] powerpc: Decode the pte-lp-encoding bits correctly. In-Reply-To: <20130304054848.GE27523@drongo> References: <1361865914-13911-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <1361865914-13911-10-git-send-email-aneesh.kumar@linux.vnet.ibm.com> <20130304054848.GE27523@drongo> Date: Mon, 04 Mar 2013 17:22:50 +0530 Message-ID: <87vc971iwd.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Paul Mackerras Cc: benh@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Paul Mackerras writes: > On Tue, Feb 26, 2013 at 01:34:59PM +0530, Aneesh Kumar K.V wrote: >> From: "Aneesh Kumar K.V" >>=20 >> +static inline int hpte_actual_psize(struct hash_pte *hptep, int psize) >> +{ >> + unsigned int mask; >> + int i, penc, shift; >> + /* Look at the 8 bit LP value */ >> + unsigned int lp =3D (hptep->r >> LP_SHIFT) & ((1 << LP_BITS) - 1); >> + >> + penc =3D 0; >> + for (i =3D 0; i < MMU_PAGE_COUNT; i++) { >> + /* valid entries have a shift value */ >> + if (!mmu_psize_defs[i].shift) >> + continue; >> + >> + /* encoding bits per actual page size */ >> + shift =3D mmu_psize_defs[i].shift - 11; >> + if (shift > 9) >> + shift =3D 9; >> + mask =3D (1 << shift) - 1; >> + if ((lp & mask) =3D=3D mmu_psize_defs[psize].penc[i]) >> + return i; >> + } >> + return -1; >> +} > > This doesn't look right to me. First, it's not clear what the 11 and > 9 refer to, and I think the 9 should be LP_BITS (i.e. 8). Secondly, > the mask for the comparison needs to depend on the actual page size > not the base page size. How about the below. I am yet to test this in user space.=20 static inline int hpte_actual_psize(struct hash_pte *hptep, int psize) { unsigned int mask; int i, penc, shift; /* Look at the 8 bit LP value */ unsigned int lp =3D (hptep->r >> LP_SHIFT) & ((1 << LP_BITS) - 1); penc =3D 0; for (i =3D 0; i < MMU_PAGE_COUNT; i++) { /* valid entries have a shift value */ if (!mmu_psize_defs[i].shift) continue; /* * encoding bits per actual page size * PTE LP actual page size * rrrr rrrz =E2=89=A58KB * rrrr rrzz =E2=89=A516KB * rrrr rzzz =E2=89=A532KB * rrrr zzzz =E2=89=A564KB * ....... */ shift =3D mmu_psize_defs[i].shift - mmu_psize_defs[MMU_PAGE_4K].shift; if (shift > LP_BITS) shift =3D LP_BITS; mask =3D (1 << shift) - 1; if ((lp & mask) =3D=3D mmu_psize_defs[psize].penc[i]) return i; } return -1; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org