From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752806AbdGEMZU (ORCPT ); Wed, 5 Jul 2017 08:25:20 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:60963 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751931AbdGEMZS (ORCPT ); Wed, 5 Jul 2017 08:25:18 -0400 Date: Wed, 5 Jul 2017 14:25:06 +0200 From: Peter Zijlstra To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Rik van Riel , Dave Hansen , Arjan van de Ven Subject: Re: [PATCH v4 10/10] x86/mm: Try to preserve old TLB entries using PCID Message-ID: <20170705122506.GG4941@worktop> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 29, 2017 at 08:53:22AM -0700, Andy Lutomirski wrote: > +static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, > + u16 *new_asid, bool *need_flush) > +{ > + u16 asid; > + > + if (!static_cpu_has(X86_FEATURE_PCID)) { > + *new_asid = 0; > + *need_flush = true; > + return; > + } > + > + for (asid = 0; asid < TLB_NR_DYN_ASIDS; asid++) { > + if (this_cpu_read(cpu_tlbstate.ctxs[asid].ctx_id) != > + next->context.ctx_id) > + continue; > + > + *new_asid = asid; > + *need_flush = (this_cpu_read(cpu_tlbstate.ctxs[asid].tlb_gen) < > + next_tlb_gen); > + return; > + } > + > + /* > + * We don't currently own an ASID slot on this CPU. > + * Allocate a slot. > + */ > + *new_asid = this_cpu_add_return(cpu_tlbstate.next_asid, 1) - 1; So this basically RR the ASID slots. Have you tried slightly more complex replacement policies like CLOCK ? > + if (*new_asid >= TLB_NR_DYN_ASIDS) { > + *new_asid = 0; > + this_cpu_write(cpu_tlbstate.next_asid, 1); > + } > + *need_flush = true; > +} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id C20866B0343 for ; Wed, 5 Jul 2017 08:25:16 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id c12so258124656pfj.12 for ; Wed, 05 Jul 2017 05:25:16 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id w8si17341765pfj.27.2017.07.05.05.25.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 05:25:16 -0700 (PDT) Date: Wed, 5 Jul 2017 14:25:06 +0200 From: Peter Zijlstra Subject: Re: [PATCH v4 10/10] x86/mm: Try to preserve old TLB entries using PCID Message-ID: <20170705122506.GG4941@worktop> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Rik van Riel , Dave Hansen , Arjan van de Ven On Thu, Jun 29, 2017 at 08:53:22AM -0700, Andy Lutomirski wrote: > +static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, > + u16 *new_asid, bool *need_flush) > +{ > + u16 asid; > + > + if (!static_cpu_has(X86_FEATURE_PCID)) { > + *new_asid = 0; > + *need_flush = true; > + return; > + } > + > + for (asid = 0; asid < TLB_NR_DYN_ASIDS; asid++) { > + if (this_cpu_read(cpu_tlbstate.ctxs[asid].ctx_id) != > + next->context.ctx_id) > + continue; > + > + *new_asid = asid; > + *need_flush = (this_cpu_read(cpu_tlbstate.ctxs[asid].tlb_gen) < > + next_tlb_gen); > + return; > + } > + > + /* > + * We don't currently own an ASID slot on this CPU. > + * Allocate a slot. > + */ > + *new_asid = this_cpu_add_return(cpu_tlbstate.next_asid, 1) - 1; So this basically RR the ASID slots. Have you tried slightly more complex replacement policies like CLOCK ? > + if (*new_asid >= TLB_NR_DYN_ASIDS) { > + *new_asid = 0; > + this_cpu_write(cpu_tlbstate.next_asid, 1); > + } > + *need_flush = true; > +} -- 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