Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4444510imm; Mon, 30 Jul 2018 15:01:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfoQmt/WIQDD43MgcVmBASw0FYFPQmY3I9ZzM9itiQ/gi/qXE9ieVFBv4VWVhfv/H1P9eIk X-Received: by 2002:a63:f713:: with SMTP id x19-v6mr17800336pgh.233.1532988113586; Mon, 30 Jul 2018 15:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532988113; cv=none; d=google.com; s=arc-20160816; b=qogXIOx7Gnc4VmAvI2luKIXjhRJYMEK5xRMA5BTgA5O2tBSjhRVqQRGISsw6mBLcU7 S4CEMicWeGG/W1eHiPjoA0DPU4P+ujvstWLf28BeI8P/aDLfAJTNcC5xdbxzaBgycTcL TgIbu5+u5zMS2ox/YE7oiJBExZ6uQDZEMQ4Ok/ZXZJmNfh++oYgJOZ3dxHqUi4ZPWTYe NkEjWOGiPrGKyiqOMhbjdXFqnQj86H99eS1xQR3nR5dQq/8mYgwmanWltNL8T72ar0J/ U8YEaV6b5jlGBMO77awEPGtwTCPrxt6Nnyl9+2CUefpjdb3g1Vxte0tpLeKu1XBiOco/ 46XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=HBCsCVae+BF+nuVLp/xK3snzjYAJeCrH7C7H7w3ttOQ=; b=eSatnr3Cwi2ogghtuDIwRuWhthWkFrIOxI6n8fyFyYLtkjNfggVWU3nEBL00Ju1fi/ eRm6DiJs2X+i+J9ywO1yMjQ6wzr8ASjeWtwhaejOAP5wETgP1qy2WuPNybEU5xRg2NFF 8WhEsl6ySsNMmQvZsQ4Rs1XNvaWOAWrBHGZF1MSoTzn63Y1IwETXzIv5QQQVBbE+TilC HPC73PIgYW1XRnKxZUPMkEWWiHUVYd3jrWCdPV6D3XSh2N+CbqGhpaPA5ZKISaSiVF13 WVwpqCRqyNF3n30m+b+9hW90+W6F0CR0G0C+tvNDuscejPat0z/Ao85riPW4P9vhrSV3 PyHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WJUX5sAm; 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 j185-v6si1282000pgc.419.2018.07.30.15.01.39; Mon, 30 Jul 2018 15:01:53 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=WJUX5sAm; 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 S1731977AbeG3Xho (ORCPT + 99 others); Mon, 30 Jul 2018 19:37:44 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33830 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbeG3Xho (ORCPT ); Mon, 30 Jul 2018 19:37:44 -0400 Received: by mail-pg1-f193.google.com with SMTP id y5-v6so7964807pgv.1 for ; Mon, 30 Jul 2018 15:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HBCsCVae+BF+nuVLp/xK3snzjYAJeCrH7C7H7w3ttOQ=; b=WJUX5sAmzc5VsJIzklnhd9kaEw/42xLRwxRCgQop92mcIkRGBcXcnSONfpYMUHhH4M uk+E5nLJPw8CwL+LSJ3sgYVvqhcq1Ig8LRz9s6fhgWUwS2aUEEdkUCuLIK9MBeAGPMrk 6X6bL1PRJj8bu1a67ogPqNygLg123PRoTJgfiQhGqSJkqE4gK1sGVS1kWGDfZ7XKQgYe QGl26Igw4+90MOFfbaAIOiHngNixR5XBY6GzMnjUDvlqvNV4RZ7gvfdY/sIXxYI3nQTw KjfrHY6UbUjTlHGHJOSmPv9j3iyQ1T3TV93AGN7tAYhTix3uSJ6Fc8RM5VwLCgUGOVX7 nb4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HBCsCVae+BF+nuVLp/xK3snzjYAJeCrH7C7H7w3ttOQ=; b=nuzB8OjmrWp9D8JdgS+Zlbr8JeaCzpVZc8H7d6t9SIXMcoAy9PWX8+sHVqnHxTANXk 4Zc9OVklD9YdP5Tf0LeBGX+SeYm1ITbk1vUeZ3HXqnbtBuCwBqgfqtEXyFfLZ5dF4fMo sJwIcVXRrk/u8IpaWuPXkUTGi6fN1tUsbttjp5yMqSGkPTjZODrFlgyReYN+Eu6p9kfk 9t/sIzh2gncH2cYN9YqzcdstN5nEmnx5wOmkmoZXojKHMJEScPaiqax48hxUM6yX0EMs AU4HseumxgP4YMjqZ/xPFu0ajKiPyRQ4PH2Ket2ST2IVWSualjNa6IqFFAWqiwFvURwv nzFA== X-Gm-Message-State: AOUpUlGQf2QBxjYn43vHlPXE0QR5p9yqj/u/xJ9q1XBIW7gavWfQzFB+ XIaQN1yhgVU1eC2oYWBxZo//FA== X-Received: by 2002:a65:6551:: with SMTP id a17-v6mr17881647pgw.132.1532988043742; Mon, 30 Jul 2018 15:00:43 -0700 (PDT) Received: from ?IPv6:2600:1010:b000:9cc9:ec6b:3393:cbdb:226f? ([2600:1010:b000:9cc9:ec6b:3393:cbdb:226f]) by smtp.gmail.com with ESMTPSA id e126-v6sm25647864pfg.31.2018.07.30.15.00.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 15:00:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 11/11] mm,sched: conditionally skip lazy TLB mm refcounting From: Andy Lutomirski X-Mailer: iPhone Mail (15G77) In-Reply-To: <1532987170.28585.52.camel@surriel.com> Date: Mon, 30 Jul 2018 15:00:40 -0700 Cc: Andy Lutomirski , Linus Torvalds , Peter Zijlstra , LKML , kernel-team , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , Catalin Marinas , Benjamin Herrenschmidt Content-Transfer-Encoding: quoted-printable Message-Id: <91F4157A-8004-46EC-AE04-F2F338B0D5BB@amacapital.net> References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-11-riel@surriel.com> <20180729155452.37eddc11@imladris.surriel.com> <20180730095502.GG2494@hirez.programming.kicks-ass.net> <1532961011.28585.30.camel@surriel.com> <20180730162653.GM2494@hirez.programming.kicks-ass.net> <1532978146.28585.32.camel@surriel.com> <1532979368.28585.33.camel@surriel.com> <1532987170.28585.52.camel@surriel.com> To: Rik van Riel Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jul 30, 2018, at 2:46 PM, Rik van Riel wrote: >=20 >> On Mon, 2018-07-30 at 12:49 -0700, Andy Lutomirski wrote: >>=20 >>=20 >> I think it's a big step in the right direction, but it still makes be >> nervous. I'd be more comfortable with it if you at least had a >> functional set of patches that result in active_mm being gone, >> because >> that will mean that you actually audited the whole mess and fixed >> anything that might rely on active_mm pointing somewhere or that >> might >> be putting a value you didn't take into account into active_mm. IOW >> I'm not totally thrilled by applying the patches as is if we're still >> a bit unsure as to what might have gotten missed. >>=20 >> I don't think it's at all necessary to redo the patches. >>=20 >> Does that seem reasonable? >=20 > Absolutely. I tried to keep ->active_mm very similar > to before for exactly that reason. >=20 > Lets go through all the places where it is used, in > x86 and architecture independent code. I have not > checked other architectures. >=20 > It looks like we should be able to get rid of > ->active_mm at some point, but a lot of it depends > on other architecture maintainers. >=20 >=20 > arch/x86/events/core.c: > - get_segment_base: get current->active_mm->context.ldt, > this appears to be for TIF_IA32 user programs only, so > we should be able to use current->mm here ->mm sounds more correct anyway >=20 > arch/x86/kernel/cpu/common.c: > - current task's ->active_mm assigned in two places, > never read >=20 > arch/x86/lib/insn-eval.c: > - get_desc() gets current->active_mm->context.ldt, this > appears to be only for user space programs Same as above >=20 > arch/x86/mm/tlb.c: > - this series adds two places where current->active_mm is > written, it is never read >=20 > arch/x86/platform/efi/efi_64.c: > - current->active_mm is set to efi_mm for a little bit, > with irqs disabled, and then changed back, with irqs still > disabled; we should be able to get rid of ->active_mm here > - in the init code, ->active_mm is set to efi_mm as well, > presumably the kernel automatically switches that back on > the next context switch; this may be buggy, since preemption > is enabled and a GFP_KERNEL allocation is just a few lines > below Ick. This should mostly go away soon =E2=80=94 most EFI code will move to a r= eal thread. >=20 > arch/x86/power/cpu.c: > - fix_processor_context() calls load_mm_ldt(current->active_mm);, > we should be able to use cpu_tlbstate.loaded_mm instead Agreed >=20 > drivers/cpufreq/pmac32-cpufreq.c: > - pmu_set_cpu_speed() restores current->active_mm - don't know if > anyone still cares about 32 bit PPC :) >=20 I think we should only remove active_mm when the new #define is set. So this= doesn=E2=80=99t need to change. > drivers/firmware/efi/arm-runtime.c: > - efi_virtmap_unload switches back the pgd to current->active_mm > from &efi_mm; that mm could be stored elsewhere if we excised > ->active_mm everywhere Ditto IOW the active_mm refcounting may be genuinely useful for architectures that= are not able to efficiently shoot down remote lazy mm references in exit_mm= ap(). I suspect that ARM64 may be in that category.