Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp414127imm; Thu, 21 Jun 2018 21:54:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLbtE/ZR85xT7WT71hQFZJKh+DtUWK7Ve3Ea5X2Hxy4pi8r6n3+yyHc1GmcTQWPDo2AkBdD X-Received: by 2002:a17:902:5488:: with SMTP id e8-v6mr41545pli.137.1529643256409; Thu, 21 Jun 2018 21:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529643256; cv=none; d=google.com; s=arc-20160816; b=PQtR5TbuvMk5TaDxake6sPfyWrbjGVe8iHxaKK55VqXE9GUnne4PuY2HX6eh1KsNRD iZT2etQeiTNPNVgIBjDrKGz/cb7MS5tRbS6Z6erVfuEd4T61n/Di+zCxwBoypaK8ilt1 e68HP3R0ba4ed7+pocbACE7Eatpgo/AEYJmieHr62R+XZoExLwS0XjiVukukV/B4yhu9 jLS8me4TJLeyGGDRdn6/axylK3UnIx9i+lEeD6/mEvm5gvRW3fgWOUvYl9d3STmLhzQF QzEDAH/93p4eqVP1PdZPAaWiv9OECcx8OQB7IW5FLEB1PfywixkF/x8XTEDhU1V4DhP5 mKcQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=M8+qMHzZIx+mdLYxwduEyc3SV+K3dZR8NDGDti6KiHc=; b=nKyxTLZAbK72J5V5Z+Dh2AvQtmEpNPWaWhoW/5m1/5+QL5LrE6NB1/bMGwkGeTJGko yK+ZQ9JQ/aBqAOTzWFzRcNJV7MsIla7oclp2JjEbcNFx/u9TUWpyzo3im0VelYVEzcEY tvzxVkwkWaO/lCLCyGn4C1KZ6yEcwupnwT1yrxxQ+uvWXMlWs8glhmRhWXP1OqfiIJLY Sjf2wtOS4KKBs0BOzOpSiGsJS1K9KG3W0Av4YlOZcv2HNTjxyz7FFZV7vA5o9BJHHJ/Q pswk+1Ut1Q4VNRYEE9mJn40t8Fr9nJhuZw3Bl9BWW3m6zBvuLKXltTbH8QDVrlgK0gQB qLog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J9vJJFMh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si941725pgb.373.2018.06.21.21.54.01; Thu, 21 Jun 2018 21:54:16 -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=pass header.i=@gmail.com header.s=20161025 header.b=J9vJJFMh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbeFVEx0 (ORCPT + 99 others); Fri, 22 Jun 2018 00:53:26 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44018 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbeFVExY (ORCPT ); Fri, 22 Jun 2018 00:53:24 -0400 Received: by mail-pl0-f67.google.com with SMTP id c41-v6so2837398plj.10 for ; Thu, 21 Jun 2018 21:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M8+qMHzZIx+mdLYxwduEyc3SV+K3dZR8NDGDti6KiHc=; b=J9vJJFMhFZ3gaGz3gRoJE7I6ubZg1TGLRXt9yRkOFs2qq46UEkwJTwB9rATGWp9efy iFDNMUCk6ikw8VDUIJmbOgmKtbbeCLJryg9m73o3Yro9wl5Mv0MwJ7zn7BgBxTLLDZ4k tiOmCB6i6swePUcJpu5g4vqC7kkUumbcPNFUcWWNXPBlzLPevwa03JMPJonzmqZuhAfi w5A6lo8q6kdlDtWFjpkK3SNIW3hAKxEuJ+qW1zhh3ewB2BRLxNvCnCqBEPnMbpmjAp0m fvstUeLQE3FLrSibIssKKajOlCwPTsG6gsr92erEDakN39Aal0XGjDCgm8AbDXRY7HdS nWBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M8+qMHzZIx+mdLYxwduEyc3SV+K3dZR8NDGDti6KiHc=; b=QEkBpPYVWzLD1ina/RPYN0sfDCwsRvQfY98T6Q1/HTKUUUvd3w/dN5nCwDAT74+/Fe HG324HgS0X7RigxwnKrEAA/DJ0s2mZNCOnDmNkz5p014POqWlWivsoLWO0fZJb7G/+lP 9563kWHN3bQ2EKdDmBMV6fIga/9KAVGSbeqPRibQ8YMSXaYJ89R7dTTcoJBqXRK56rTr jqQTv4crzr0brNP3dg10AJT47CdZwoYNZ/9Z1NGm7RfXnxbDWRXJToqOn6/s2adsvTc7 oLB+t5BNV9a0B5WuwCrOjIpBVgGbaQ4tGyPQWOVsiXFOJ10VWtkMaWEP384zo0yQqglr VPOw== X-Gm-Message-State: APt69E1HmA8lT+ZhhuZYv0vAff7QMc4XgscbwDONkW1u5praykvRTTuY BvvkLudmzLP7+RTLNdtkgzA= X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr46873pls.37.1529643204475; Thu, 21 Jun 2018 21:53:24 -0700 (PDT) Received: from roar.ozlabs.ibm.com (s169.156.222.122.fls.vectant.ne.jp. [122.222.156.169]) by smtp.gmail.com with ESMTPSA id q24-v6sm9684311pfh.26.2018.06.21.21.53.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 21:53:23 -0700 (PDT) Date: Fri, 22 Jun 2018 14:53:17 +1000 From: Nicholas Piggin To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "Aneesh Kumar K.V" , Thiago Jung Bauermann , Ram Pai , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 13/26] ppc: Convert mmu context allocation to new IDA API Message-ID: <20180622145317.668cdafa@roar.ozlabs.ibm.com> In-Reply-To: <20180622043815.GA31255@bombadil.infradead.org> References: <20180621212835.5636-1-willy@infradead.org> <20180621212835.5636-14-willy@infradead.org> <20180622121511.00ae9d00@roar.ozlabs.ibm.com> <20180622043815.GA31255@bombadil.infradead.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Jun 2018 21:38:15 -0700 Matthew Wilcox wrote: > On Fri, Jun 22, 2018 at 12:15:11PM +1000, Nicholas Piggin wrote: > > On Thu, 21 Jun 2018 14:28:22 -0700 > > Matthew Wilcox wrote: > > > static int alloc_context_id(int min_id, int max_id) > ... > > > - spin_lock(&mmu_context_lock); > > > - err = ida_get_new_above(&mmu_context_ida, min_id, &index); > > > - spin_unlock(&mmu_context_lock); > ... > > > @@ -182,13 +148,11 @@ static void destroy_contexts(mm_context_t *ctx) > > > { > > > int index, context_id; > > > > > > - spin_lock(&mmu_context_lock); > > > for (index = 0; index < ARRAY_SIZE(ctx->extended_id); index++) { > > > context_id = ctx->extended_id[index]; > > > if (context_id) > > > - ida_remove(&mmu_context_ida, context_id); > > > + ida_free(&mmu_context_ida, context_id); > > > } > > > - spin_unlock(&mmu_context_lock); > > > } > > > > > > static void pte_frag_destroy(void *pte_frag) > > > > This hunk should be okay because the mmu_context_lock does not protect > > the extended_id array, right Aneesh? > > That's my understanding. The code today does this: > > static inline int alloc_extended_context(struct mm_struct *mm, > unsigned long ea) > { > int context_id; > > int index = ea >> MAX_EA_BITS_PER_CONTEXT; > > context_id = hash__alloc_context_id(); > if (context_id < 0) > return context_id; > > VM_WARN_ON(mm->context.extended_id[index]); > mm->context.extended_id[index] = context_id; > > so it's not currently protected by this lock. I suppose we are currently > protected from destroy_contexts() being called twice simultaneously, but > you'll notice that we don't zero the array elements in destroy_contexts(), > so if we somehow had a code path which could call it concurrently, we'd > be seeing warnings when the second caller tried to remove the context Yeah that'd be an existing bug. > IDs from the IDA. I deduced that something else must be preventing > this situation from occurring (like, oh i don't know, this function only > being called on process exit, so implicitly only called once per context). I think that's exactly right. Thanks, Nick