Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1308612ybl; Wed, 28 Aug 2019 12:40:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0kXMZJqfCVHTcyns89ujMUv8AJGw37LppEYdayFssbcy5noCmQ59d78GtYVXEO51giyRA X-Received: by 2002:a17:902:5a09:: with SMTP id q9mr5944290pli.191.1567021230991; Wed, 28 Aug 2019 12:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567021230; cv=none; d=google.com; s=arc-20160816; b=xL7OvIN++Ly7HhvKfzgqZ+dkJ64UWYez2ZV1eL6AmfFyA0sva0BVhvQut1KaJbFH0I /DoMuDnwY5BLRAbARGN2rvUJnWJ+RUs93+eImxmkfr5CQvOHHhj301IW/9Nm3o/MK+Zn IcSKXyK3Eo9EIptxWIr8R2hKUi5/QJFEo3luUsQcnytD36X83zV2FpfCj5Ii/WHiWHVL lQrVMsEo4uZmNDlycH5Pf8h7cv4EEGZThPPYN7fe4TfJIKMbso8XXqeJ9lNdF6S/UUfK iU4NzwtgL9NriBU4jVUTfhHOJaudXouTJCRQS9u08WPDDSe0bpCrOgbx8N5kXEPPhUkP yCjw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=v6I0NxJQJkD1JgL9Whr1E8kXbKnnwerSju7V9v+AMdA=; b=L+/9DCtGUOMeF7M5tMCwqJnAzqqoW3j0dSR2h11F9RVipSpMVt6CnAck86ClIVq25i YJBs1xysRndk9kNQ6csHJN3NRWe+bL2BaYMWhphBALMyZRqx3c+K007w4h0o3HnwrE/P gaq+HyTAGE2qpTO2tOlnrbHFrNZCaQImhXqctZNq47Q517PEou4IE1SHEbumcarivIbs ABX0QC6ZfIFPCACTxpFGoYVRxQRexUZCxQnjBxXvFXdsME3KDbayK5+qHaKsQ4eQ9ATE 3L04u+yfIPZlTzgsDXeMlKezPOJ/f5uR3PTnia+kzzwEEXYc95A8kgphXNgDbLuuC9jH GZFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=DQgpMf8a; 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 w16si148600pjn.71.2019.08.28.12.39.59; Wed, 28 Aug 2019 12:40:30 -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=@rasmusvillemoes.dk header.s=google header.b=DQgpMf8a; 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 S1726953AbfH1Tip (ORCPT + 99 others); Wed, 28 Aug 2019 15:38:45 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39809 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbfH1Tip (ORCPT ); Wed, 28 Aug 2019 15:38:45 -0400 Received: by mail-ed1-f67.google.com with SMTP id g8so1292202edm.6 for ; Wed, 28 Aug 2019 12:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v6I0NxJQJkD1JgL9Whr1E8kXbKnnwerSju7V9v+AMdA=; b=DQgpMf8ao0gcsEtBQ7MRr/p3CHj1R5lHbOEo69FnLPGYitpp4vCxTy9KpNSIGqPaHS FukOT0+NWkJm2PbBnj1hhcvBTdsWnKOnM6V+aF1EQ/b267OOWqzKVlprsDDJEEMg19e+ 9VMRsZyhg5YF1lEupwdc0HAhuXSCI+n7hxm3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v6I0NxJQJkD1JgL9Whr1E8kXbKnnwerSju7V9v+AMdA=; b=SyLXsxZDWfyg+eWNs0d9ALfwSDWKpt0C7z4wPgpqnV6h9dkFnOPgtkYQAvNNRfHp+e a9GLKmcJYNdrizpoJGNjJSm4ndgl9RurcN3WfOf0BxaN63lDHsxRgPSxSitQwkBIzyzJ WHP3Mzrs12lyQ3QdyAbARQgG3n996yEFZDEzO/THAenO/saNpdyLbJzjc9klH8lZILPP DieZ5htDF3QDSn7DUYfqWtYEkQLUdKNizHYC8cPTNHU6Ed93vtbYRx0PElwQq2r0ow7o l6YH25Jv7pqrfJGJ2Da2DGbhOfGk7O5RFEX4kOcrXbaj9AGPkLQb2kgium89OSdHFLwr s/KA== X-Gm-Message-State: APjAAAVvDPVk6lUvMtpr6FrB/47NKBcaQI4An9cSgSeqPd2ykE+hKsJK 4hwsFH92eDdhdfHSizY4W796Xw== X-Received: by 2002:a50:b825:: with SMTP id j34mr6104619ede.58.1567021123668; Wed, 28 Aug 2019 12:38:43 -0700 (PDT) Received: from prevas-ravi.prevas.se (ip-5-186-115-35.cgn.fibianet.dk. [5.186.115.35]) by smtp.gmail.com with ESMTPSA id ni7sm38990ejb.57.2019.08.28.12.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 12:38:43 -0700 (PDT) From: Rasmus Villemoes To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] x86: mmu.h: move mm_context_t::lock member inside CONFIG_MODIFY_LDT_SYSCALL Date: Wed, 28 Aug 2019 21:38:35 +0200 Message-Id: <20190828193836.16791-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The placement of the lock member in mm_context_t suggests that it is used to protect the vdso* members, but AFAICT, it is only ever used under #ifdef CONFIG_MODIFY_LDT_SYSCALL. So guarding the member by the same config option is a cheap way to reduce sizeof(mm_struct) by 32 bytes (only for !CONFIG_MODIFY_LDT_SYSCALL kernels, of course). Signed-off-by: Rasmus Villemoes --- arch/x86/include/asm/mmu.h | 11 ++++++++--- arch/x86/include/asm/mmu_context.h | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h index e78c7db87801..b1bb47a3577b 100644 --- a/arch/x86/include/asm/mmu.h +++ b/arch/x86/include/asm/mmu.h @@ -30,14 +30,13 @@ typedef struct { #ifdef CONFIG_MODIFY_LDT_SYSCALL struct rw_semaphore ldt_usr_sem; struct ldt_struct *ldt; + struct mutex lock; #endif - #ifdef CONFIG_X86_64 /* True if mm supports a task running in 32 bit compatibility mode. */ unsigned short ia32_compat; #endif - struct mutex lock; void __user *vdso; /* vdso base address */ const struct vdso_image *vdso_image; /* vdso image in use */ @@ -56,10 +55,16 @@ typedef struct { #endif } mm_context_t; +#ifdef CONFIG_MODIFY_LDT_SYSCALL +#define INIT_MM_CONTEXT_LOCK(mm) .lock = __MUTEX_INITIALIZER(mm.context.lock), +#else +#define INIT_MM_CONTEXT_LOCK(mm) +#endif + #define INIT_MM_CONTEXT(mm) \ .context = { \ .ctx_id = 1, \ - .lock = __MUTEX_INITIALIZER(mm.context.lock), \ + INIT_MM_CONTEXT_LOCK(mm) \ } void leave_mm(int cpu); diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 9024236693d2..ac8e3ef8a774 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -82,6 +82,7 @@ static inline void init_new_context_ldt(struct mm_struct *mm) { mm->context.ldt = NULL; init_rwsem(&mm->context.ldt_usr_sem); + mutex_init(&mm->context.lock); } int ldt_dup_context(struct mm_struct *oldmm, struct mm_struct *mm); void destroy_context_ldt(struct mm_struct *mm); @@ -186,8 +187,6 @@ void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk); static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { - mutex_init(&mm->context.lock); - mm->context.ctx_id = atomic64_inc_return(&last_mm_ctx_id); atomic64_set(&mm->context.tlb_gen, 0); -- 2.20.1