Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2560005imm; Sat, 28 Jul 2018 21:22:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmqRjzEbJ9p1NHPnotFuKMqESa/qTwh3KhAPAW0yoekLq6mFCWIlAAaPaxQm4pyODjLSmx X-Received: by 2002:a63:1e66:: with SMTP id p38-v6mr11574499pgm.376.1532838160366; Sat, 28 Jul 2018 21:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532838160; cv=none; d=google.com; s=arc-20160816; b=rs3SsYjnEoidkjO9xeMgMFnGCEEFJwVITyzAEGzGCvK0GfijIJ66BdCHpsXhZURECf tdDvyol+03mCLGJoFmkC7yskKPuIPA+2I+Hlq2KfUgYa3oid9xDXhO75T8eqOOnSTO6A qgSgCmBMIwSd95T8ldRCMHq57QYoWflKsVhpLlaSWR1gvrX1Cxu2n9V67+jvJ1NlB8Vn lr75e/fVbCUz8MMYHUyivCtwnhLqdfRpMLd4gBJc4s1xV50Fqderno4Si8ehdiMvohxm GNOrVPV5N3KxlDaIRiOIW5FJg02Pcxo1RobC/fTMNLSesRfhfyUYNKbOb1NA91Im0efZ qXbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Y4QJWPz34uJj2AX0/xgC9VM1FZtP6neMG1v5M268SWE=; b=swSj+2DAR6lhndIF46jQn6p6iGWzb1e2MBW15EcJ+7574arxlpoVtfU15HmcFZUlAe gPR+p6mCRKexy8JJWLvx1S3iRnZsyZs/htr7b6zH35nBjUOxfTHEoB+meP2m4d155pOj DKO643jChCa2RGGZQdtXwIRc4QMIspCLQBaZyps+Ee5CxKKiVs747Pc9y56IjIwwXhud TZ+ZVve8Qh6pXeDib4+h3H+st3IT/WHGew2F18I5X9GOkq/ETBP9J9hTx80qBk5pwpDx GOv9rSMbH+V+ROQK/X5DyHW+jztRZ6ouA69hlRRDVPdg7uVgK55dObECIkUKPX9lvsPP tHMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yLXJlAIi; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11-v6si6875739plq.456.2018.07.28.21.22.26; Sat, 28 Jul 2018 21:22:40 -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=@kernel.org header.s=default header.b=yLXJlAIi; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbeG2Fui (ORCPT + 99 others); Sun, 29 Jul 2018 01:50:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:47768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbeG2Fui (ORCPT ); Sun, 29 Jul 2018 01:50:38 -0400 Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B5D2208A6 for ; Sun, 29 Jul 2018 04:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532838099; bh=lUf9A+GB2sd/heiAH3nlexp90t4NRbznnCXyMTWFDTU=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=yLXJlAIiZn4iDazIclJlNKTuv1QXqOBAZfy3kzL80fa5TrKenPyTZ63Nttu5RUBIn GHSdg4+XrXK3KikbvA0ijc27zVK1wNTDGQCjJpTe+fG+/lvCzyC9qPAhVVPkCLqERL XLZv30DuHxcJUDB6MzGDQdQRyZntS/BSkjJPcIRk= Received: by mail-wm0-f51.google.com with SMTP id s9-v6so9416854wmh.3 for ; Sat, 28 Jul 2018 21:21:39 -0700 (PDT) X-Gm-Message-State: AOUpUlGStRLABty6A2t6lG7oiKTYE62AVYPIGW9NC+xrX4ULtVvwiC18 JIRYBaGhWSU3GsoQfBjly3VJEt+wbWlvInlNaa+TVg== X-Received: by 2002:a1c:f30d:: with SMTP id q13-v6mr9706620wmq.36.1532838097968; Sat, 28 Jul 2018 21:21:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:548:0:0:0:0:0 with HTTP; Sat, 28 Jul 2018 21:21:17 -0700 (PDT) In-Reply-To: <20180728215357.3249-11-riel@surriel.com> References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-11-riel@surriel.com> From: Andy Lutomirski Date: Sat, 28 Jul 2018 21:21:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 10/10] mm,sched: conditionally skip lazy TLB mm refcounting To: Rik van Riel Cc: LKML , kernel-team , Peter Zijlstra , Andrew Lutomirski , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , will.daecon@arm.com, Catalin Marinas , Benjamin Herrenschmidt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 28, 2018 at 2:53 PM, Rik van Riel wrote: > Conditionally skip lazy TLB mm refcounting. When an architecture has > CONFIG_ARCH_NO_ACTIVE_MM_REFCOUNTING enabled, an mm that is used in > lazy TLB mode anywhere will get shot down from exit_mmap, and there > in no need to incur the cache line bouncing overhead of refcounting > a lazy TLB mm. Unless I've misunderstood something, this patch results in idle tasks whose active_mm has been freed still having active_mm pointing at freed memory. This isn't strictly speaking a bug, but it's extremely confusing and risks all kinds of nasty errors. That's why I prefer the approach of actually removing the active_mm field on x86 rather than merely removing the refcount. I realize that this will add more ifdeffery and make the patch a bit bigger, but I think it'll be much more robust. Not to mention that it will save a pointer an a refcount per mm_struct, but that barely matters.