Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3630599rdg; Wed, 18 Oct 2023 00:46:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtqjgQfdB/OQmBiYdtAubn/E7NFjtDuo/ApuozEg3jhY49BMGBiy+Tv/munSGrZZqIYaen X-Received: by 2002:a05:6a00:13a1:b0:6b3:80f8:7e91 with SMTP id t33-20020a056a0013a100b006b380f87e91mr6906030pfg.9.1697615214028; Wed, 18 Oct 2023 00:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697615213; cv=none; d=google.com; s=arc-20160816; b=PbyfNm2UE+cvlZPjHLv+3SCWvcEU4ZcwBiOY3O34VFKwzPb9NsQFN0OJ+Agi9h01iS 1c3qEpFEXJtGYplYWBue/BAPXCegbPZEOsbg8sYJX2KQrp8hwgp2VLbC0GNDCs5hD86s C7jwHMi/T4WHSCAWI9dxRypAudObEM/JdefLgjaFCskknk0KxaHbUPh1r6KYjCWEhf1i GqgtFKis/4pZ67fjCQqkyGerXWt1jZ6yv0wp4KfEYWfuSWIi7DHv1YhGJrITsEfCx25x RtICcOLDdtknTEjKnyFt6fvbI/MYaVfi09BgGEp7qlJnqWS7CAaq+RKQ3iH0M1dNNtdG bS+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dA7saKMM+YbXWR6urBcqMWPufxj1re/P00wpI5eX550=; fh=/Dnf++/2xG0Xi30TGscvcX3UaoYjzLSxPPap0bUcRsE=; b=dhoLTv9zz9eYr4jFPLYXO1vMBIQ+vYBu870Zfnphq98uEYCTCBeu2gic3/EhFGu6f+ LxRM/WtsQLR8BQhmOMjHxM+/gTB1x3Bz+/RL8iJWThrWTt5OAJMv2Iu4BFgkY4YayLf9 AUVtklYqnboK12q3rxIJPgVI5MlpDZeVZAiTpyq5B//H6+/PO2ACRZwWmFBExqaQ8BdX l6oi3WIE/UiQOGF/Ms4FVj3Ykm/LSa19yjR/HRDUcrJ9HPMl5ffZEKl6mw8/ceoJnTnB tuvz6AyJorpbDmQpPWNLyMJYLuLfRTyNwsguh1qw5mc6xXcmsn1gkmZEexsV2qzPzAMN YYnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=InnwkyIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u14-20020a056a00158e00b006be322191e1si3665362pfk.254.2023.10.18.00.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 00:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=InnwkyIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AE91080CCD37; Wed, 18 Oct 2023 00:46:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344542AbjJRHqp (ORCPT + 99 others); Wed, 18 Oct 2023 03:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjJRHqm (ORCPT ); Wed, 18 Oct 2023 03:46:42 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 651E9C6 for ; Wed, 18 Oct 2023 00:46:40 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-53db360294fso11441229a12.3 for ; Wed, 18 Oct 2023 00:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697615199; x=1698219999; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dA7saKMM+YbXWR6urBcqMWPufxj1re/P00wpI5eX550=; b=InnwkyIXrqag5kgob2GAcvQUFlkGEyGSGA0UDzeyk11yBj1b8zMZ7rCvq51lFmONbO 3gDL9rKUP5Hc/5+3kGVMs9R6xLwc38bI9sEsIC8XfY5FhysSzzvhAW8/NESd1pz8hY3h dLrQ+rKoXIOKJWHYYDcSAiqUiUt3Opt+yl+47QeqxygvJG3pr7Jbb3MUmi446WzCd9tD jnP4KFgnZxL7d1PvreLYw3rCBSlFkdHXmE6ljZabUoih9TtHMLm2OD3iLoYTGd0UHCLN bRkr4eDQUcrfKKsFXRrY0fLUEA0T7wEQjhZVrkeZU2IFvImGJ9KHBfQxNVL4j+vmHyt6 H9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697615199; x=1698219999; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dA7saKMM+YbXWR6urBcqMWPufxj1re/P00wpI5eX550=; b=s2trC13XZGqCsd8YEKaSTQDf1a2EK+JcuksZQ47fa8BTZoh/ffRr+W3hfzh0R8Npd0 VoncWfhbESbPtWx/idw3BMgK3Eo+sRHjB+FdH9hYzJulRemNh/8H0LfXgOH6NATRsCOn MDV1XAI8wGaaPI/25qWp95Sc/IXz856XXuvYPmvByih9tJwo4lTpTKE9/0wR4BQiMQ1H ZEDlTJEgGXZ2Nf2Jbr+t9y1U0uZVlp4XIrV7zjDaa9D1GYrEnyvk4SAK1YQVQjWh6ypI bZ5nhboI/ttco7wi5rpby2Al7DrfCwi+47ovM4TPsf4vGPz+uF7v3dG0Se9MjbnNV9FD cWvA== X-Gm-Message-State: AOJu0YyeHrwU/dZy8HvUpZUNtvs2zM2qLtzdnKCC3R3rS4S3d+QfBFEf hWkz5vUNJivk6erugVjwLafggI1p4noWeTrebVo= X-Received: by 2002:a05:6402:510d:b0:53e:46b0:32be with SMTP id m13-20020a056402510d00b0053e46b032bemr3534936edd.34.1697615198477; Wed, 18 Oct 2023 00:46:38 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> <0617BB2F-D08F-410F-A6EE-4135BB03863C@vmware.com> <7D77A452-E61E-4B8B-B49C-949E1C8E257C@vmware.com> <9F926586-20D9-4979-AB7A-71124BBAABD3@vmware.com> In-Reply-To: From: Uros Bizjak Date: Wed, 18 Oct 2023 09:46:26 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds Cc: Nadav Amit , "the arch/x86 maintainers" , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 00:46:51 -0700 (PDT) On Tue, Oct 17, 2023 at 11:53=E2=80=AFPM Linus Torvalds wrote: > > On Tue, 17 Oct 2023 at 14:06, Uros Bizjak wrote: > > > > But adding the attached patch on top of both patches boots OK. > > Funky. > > Mind adding a > > WARN_ON_ONCE(!active_mm); > > to there to give a nice backtrace for the odd NULL case. [ 4.907840] Call Trace: [ 4.908909] [ 4.909858] ? __warn+0x7b/0x120 [ 4.911108] ? begin_new_exec+0x90f/0xa30 [ 4.912602] ? report_bug+0x164/0x190 [ 4.913929] ? handle_bug+0x3c/0x70 [ 4.915179] ? exc_invalid_op+0x17/0x70 [ 4.916569] ? asm_exc_invalid_op+0x1a/0x20 [ 4.917969] ? begin_new_exec+0x90f/0xa30 [ 4.919303] ? begin_new_exec+0x3ce/0xa30 [ 4.920667] ? load_elf_phdrs+0x67/0xb0 [ 4.921935] load_elf_binary+0x2bb/0x1770 [ 4.923262] ? __kernel_read+0x136/0x2d0 [ 4.924563] bprm_execve+0x277/0x630 [ 4.925703] kernel_execve+0x145/0x1a0 [ 4.926890] call_usermodehelper_exec_async+0xcb/0x180 [ 4.928408] ? __pfx_call_usermodehelper_exec_async+0x10/0x10 [ 4.930515] ret_from_fork+0x2f/0x50 [ 4.931894] ? __pfx_call_usermodehelper_exec_async+0x10/0x10 [ 4.933941] ret_from_fork_asm+0x1b/0x30 [ 4.935371] [ 4.936212] ---[ end trace 0000000000000000 ]--- > > That code *is* related to 'current', in how we do > > tsk =3D current; > ... > local_irq_disable(); > active_mm =3D tsk->active_mm; > tsk->active_mm =3D mm; > tsk->mm =3D mm; > ... > activate_mm(active_mm, mm); > ... > mmdrop_lazy_tlb(active_mm); > > but I don't see how 'active_mm' could *poossibly* be validly NULL > here, and why caching 'current' would matter and change it. I have also added "__attribute__((optimize(0)))" to exec_mmap() to weed out compiler bugs. The result was the same oops in mmdrop_lazy_tlb. Also, when using WARN_ON instead of WARN_ON_ONCE, it triggers only once during the whole boot, with the above trace. Another observation: adding WARN_ON to the top of exec_mmap: WARN_ON(!current->active_mm); /* Notify parent that we're no longer interested in the old VM */ tsk =3D current; old_mm =3D current->mm; also triggers WARN, suggesting that current does not have active_mm set on the entry to the function. Uros. > Strange. > > Hmm. We do set > > tsk->active_mm =3D NULL; > > in copy_mm(), and then we have that odd kernel thread case: > > /* > * Are we cloning a kernel thread? > * > * We need to steal a active VM for that.. > */ > oldmm =3D current->mm; > if (!oldmm) > return 0; > > but none of this should even matter, because by the time we actually > *schedule* that thread, we'll set active_mm to the right thing. > > Can anybody see what's up? > > Linus