Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3026842pxy; Mon, 3 May 2021 13:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzYRJT1su776RVLAzwS35vDYu+7As2tPPWzZRrQV5ODG0yWlHM3eBYN5ZzRrQsONTNrIFa X-Received: by 2002:a17:906:3a94:: with SMTP id y20mr18108633ejd.35.1620073369726; Mon, 03 May 2021 13:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620073369; cv=none; d=google.com; s=arc-20160816; b=pwDyJPvGBoGBvD2HKU4urRDwTj7x3SbWQQwHvKaVtATqQ2wJggYj7+g59t7cq7svpB mHbRgzDCnfNWnW/PaXTm8UZJKGzprK7aeuM8mFdtoLPsj7IZ6VlyyysSy3d+D4yTo255 bVG/SnKv4raP+OKIOD0ClPjE66yZAQ8WNkuDYrZdQrl9Ltqceq/doxsESUgwEj+T/IJ9 +RHHAZ7nO/7a45yPfJRUUEGAjrDHYKcfq3Mv51jFDK7C3xD1xp1Ir2xQArruXVn+0kVc Yf0SPFmKd1qwJcKjmrK6i+bKMn7q4OZzEKumHXk3ZPUQi9Nr+/oRBtnuelctttLAsidY q/zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RHhkjBqXoCWtfhvRNTDqe3jX9pPkA6881IRf/SwmPis=; b=TjVsBFqF5Y6Csz4M3B9SHLjrhqWUiKwPfM5/ANRsDC2nvGt9mnrl6s4z3rysTuRVmC oH1hn7rEJlYJ+OfnNTowYYo0tlPzw7He4FbzZvpCB9ZjG2cVB7pWzDrL2vsswf/X4t7u Op4yvDwkCTLYVmftNQ4miyaaKtvThW92BiYjLjiEQ0HdF4zLtmr/LI8yzWniv4D0Yw14 GIBevP8HY+ta5+aQKFmXA9WT9TvcWX+J+tG25w4wXrYUloE+o7rAHIupW2xy47QYhfTZ B+SCnaHjeWUFjzJ/gdmSwo9rlv/S96DUNaWac9RAgH7ffAGfeXe/6WjjPT4XlsF8YY64 zPew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IkQQITYW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id nc18si782844ejc.435.2021.05.03.13.22.25; Mon, 03 May 2021 13:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IkQQITYW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229499AbhECUWZ (ORCPT + 99 others); Mon, 3 May 2021 16:22:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:55674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbhECUWX (ORCPT ); Mon, 3 May 2021 16:22:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8A4D611AD for ; Mon, 3 May 2021 20:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620073289; bh=NFIMJkSJ9Cg2dqp0sEV+wPubHyrbBZCbTXsgOucpTMw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IkQQITYW8SotPICyZA/EYv4zYym5H+6PpbVAxQm+aID7HO1xResaX7RLkHksNo+jA 5h4RRIRsKR/oVfgvyh3KOmR0uvyizeOpviRjnn5Yfk1xFv33ziKUudsIaMecnQOpqV X/Y51QwoKBP9xiW65zZilAZfRLnxV9IMZfcKS/1gXaqvX9lW7sX/vi58cLsI4Gvi2u tID6OPZHI3B1xILphZWa3envS5Riu190QhblTZK+xpmth15oYNlHIx9odUx25bR8Ut nA7Z0ThqzbkRrU9rRPbzgWSV9JUyTjyZmR3f5GR2dc6VIeweN88ZxJ9e02wXdblE/2 BBlUu14LFtjuA== Received: by mail-ed1-f44.google.com with SMTP id i24so7833942edy.8 for ; Mon, 03 May 2021 13:21:29 -0700 (PDT) X-Gm-Message-State: AOAM5309m9F8QTP2u+naUU2FH+L5ARl27AoIAVC9jDm0dL+22YD+S7rH nWhmBsUI3dKH/xibjBohar1SKD3f9AGltoaedAXkGw== X-Received: by 2002:a05:6402:cac:: with SMTP id cn12mr12237128edb.238.1620073288337; Mon, 03 May 2021 13:21:28 -0700 (PDT) MIME-Version: 1.0 References: <8735v3ex3h.ffs@nanos.tec.linutronix.de> <3C41339D-29A2-4AB1-958F-19DB0A92D8D7@amacapital.net> In-Reply-To: From: Andy Lutomirski Date: Mon, 3 May 2021 13:21:17 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] io_thread/x86: don't reset 'cs', 'ss', 'ds' and 'es' registers for io_threads To: Andy Lutomirski Cc: Linus Torvalds , Thomas Gleixner , Stefan Metzmacher , Jens Axboe , Linux Kernel Mailing List , io-uring , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 3, 2021 at 1:15 PM Andy Lutomirski wrote: > > On Mon, May 3, 2021 at 12:15 PM Linus Torvalds > wrote: > > So generally, the IO threads are now 100% normal threads - it's > > literally just that they never return to user space because they are > > always just doing the IO offload on the kernel side. > > > > That part is lovely, but part of the "100% IO threads" really is that > > they share the signal struct too, which in turn means that they very > > much show up as normal threads. Again, not a problem: they really > > _are_ normal threads for all intents and purposes. > > I'm a bit confused, though. All the ptrace register access (AFAICS) > goes through ptrace_check_attach(), which should wait until the tracee > is stopped. Does the io_uring thread now stop in response to ptrace > stop requests? > > > > > But then that (b) issue means that gdb gets confused by them. I > > personally think that's just a pure gdb mis-feature, but I also think > > that "hey, if we just make the register state look like the main > > thread, and unconfuse gdb that way, problem solved". > > > > So I'd actually rather not make these non-special threads any more > > special at all. And I strongly suspect that making ptrace() not work > > on them will just confuse gdb even more - so it would make them just > > unnecessarily special in the kernel, for no actual gain. > > > > Is the right thing to do to fix gdb to not look at irrelevant thread B > > when deciding whether thread A is 64-bit or not? Yeah, that seems like > > obviously the RightThing(tm) to me. > > > > But at the same time, this is arguably about "regression", although at > > the same time it's "gdb doesn't understand new user programs that use > > new features, film at 11", so I think that argument is partly bogus > > too. > > > > Fair enough. But I would really, really rather that gdb starts fixing > its amazingly broken assumptions about bitness. > > > So my personal preference would be: > > > > - make those threads look even more like user threads, even if that > > means giving them pointless user segment data that the threads > > themselves will never use > > > > So I think Stefan's patch is reasonable, if not pretty. Literally > > becasue of that "make these threads look even more normal" > > I think it's reasonable except for the bit about copying the segment > regs. Can we hardcode __USER_CS, etc, and, when gdb crashes or > otherwise malfunctions for compat programs, we can say that gdb needs > to stop sucking. In general, I think that piling a bitness hack in > here is a mess, and we're going to have to carry it forward forever > once we do it. Actually... if we have your permission, I'd rather do the -EINVAL thing. Arguably, if gdb breaks cleanly, that's a win. This only affects programs using io_uring, it avoids a kludge, and hopefully it will encourage gdb to fix their bug. May we do that instead? --Andy