Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3880528ybi; Tue, 18 Jun 2019 07:59:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV2O6eU+/G45HeAp1Y9a9i5345bP82kYo1BZ1MtMLmphNOcEYXDzVpwtJeOgUCls8VBwyX X-Received: by 2002:a63:84c1:: with SMTP id k184mr3067729pgd.7.1560869959612; Tue, 18 Jun 2019 07:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560869959; cv=none; d=google.com; s=arc-20160816; b=DCJCGTnO0APIoHlRUCLAZZW0uJnHjZxDCHQCFmrWgeUuVfZfvNK27Sa221vG0pXTp1 7oP5hpDqCN0Jr9hFC+AkBik1tKU16mSopJONbsQwW43yIUau02VqmZcdqiuHp8ih3/oa Gd0sLbQYNHKVOxhRR7Eu6Xp7cUOHcsU4XXrYdFk9OtFC7QjKXNKoBDdSJXU5AintGsQE JK3hd+Ng9kogKhEUW+rz+9TTq+PJCIYhBmU7KT1Y8LSvPJmD92hBUcuObRAtykwLw5iH 1L8T0CfRa9lPNyts9ZTQ2DyzjCOt7Ox+nNK2XPlDo0YO+GhR6KqqFylMZeWKBw6GgeZB 2R0g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Z/KDfHthbOdOGujV/hIB7cX3gzqoqzxxcr4LR1mOEvE=; b=mYnJ/ap5sDWM/TXiiKe7b0dQNTjHnG6kGR06Yk8AqhwBG8SP8XhyCskQSZiXia5krT 6V9rMl0oygESZ7kDO1v050cOhBJA2vMaQMqoCP2EmNhTArRU4qjqU1lTub6ZL3dgQnVV 2UA/+j8sk1X1d5BEcop+zgsiKHo01YfU04zCBf9K329Vz9P7kaGUzLPUeqE5QCO0I4IW XpPIUZUXoNDbUEVtuoXXdT7E5YVD83zaAq7jAOPrMtBaBKiGWkBRYofjFDxzhSOAUoxE k2m0QH/WjDl0KwvrBH/UL/1qD3LkaNryeJIwndW74Fm6TaCSDE2XaNYUyd4dikSbppYM l3bQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l102si2478397pje.78.2019.06.18.07.59.04; Tue, 18 Jun 2019 07:59:19 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729586AbfFRO53 (ORCPT + 99 others); Tue, 18 Jun 2019 10:57:29 -0400 Received: from david.siemens.de ([192.35.17.14]:35859 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbfFRO53 (ORCPT ); Tue, 18 Jun 2019 10:57:29 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id x5IEu7bC031531 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 Jun 2019 16:56:07 +0200 Received: from [139.25.68.37] (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id x5IEu4CT006763; Tue, 18 Jun 2019 16:56:04 +0200 Subject: Re: [PATCH] x86: Optimize load_mm_cr4 to load_mm_cr4_irqsoff To: Dave Hansen , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Dave Hansen , Andy Lutomirski , linux-kernel@vger.kernel.org References: <0fbbcb64-5f26-4ffb-1bb9-4f5f48426893@siemens.com> From: Jan Kiszka Message-ID: Date: Tue, 18 Jun 2019 16:56:03 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18.06.19 16:41, Dave Hansen wrote: > On 6/18/19 12:32 AM, Jan Kiszka wrote: >> Thus, we can avoid disabling interrupts again in cr4_set/clear_bits. > > Seems reasonable. > > Your *_irqsoff() variants need lockdep_assert_irqs_disabled(), at least, > though. It inherits this check via __cr4_set, so I didn't add that to the outer path. > > Can you talk a bit about the motivation here, though? Did you encounter > some performance issue that led you to make this patch, or was it simply > an improvement you realized you could make from code inspection? > I ran into a downstream issue adjusting patches to this code. In a nutshell, Xenomai has something like an NMI context over most Linux code that shares some codepaths with the kernel, though. One of them is switch_mm_irqs_off, and there our checking logic warned. The rest was code inspection. For upstream, this is a micro-optimization. But given that something like switch_mm is in the path, I thought it's worth to propose. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux