From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 695D0C433ED for ; Fri, 21 May 2021 07:31:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4507E6108B for ; Fri, 21 May 2021 07:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236061AbhEUHdR (ORCPT ); Fri, 21 May 2021 03:33:17 -0400 Received: from cloud48395.mywhc.ca ([173.209.37.211]:43998 "EHLO cloud48395.mywhc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233932AbhEUHdR (ORCPT ); Fri, 21 May 2021 03:33:17 -0400 Received: from modemcable064.203-130-66.mc.videotron.ca ([66.130.203.64]:55588 helo=[192.168.1.177]) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ljzdP-0003FQ-TF; Fri, 21 May 2021 03:31:51 -0400 Message-ID: <4390e9fb839ebc0581083fc4fa7a82606432c0c0.camel@trillion01.com> Subject: Re: [PATCH] io_thread/x86: don't reset 'cs', 'ss', 'ds' and 'es' registers for io_threads From: Olivier Langlois To: Jens Axboe , Linus Torvalds Cc: Stefan Metzmacher , Thomas Gleixner , Andy Lutomirski , Linux Kernel Mailing List , io-uring , the arch/x86 maintainers Date: Fri, 21 May 2021 03:31:50 -0400 In-Reply-To: References: <8735v3ex3h.ffs@nanos.tec.linutronix.de> <3C41339D-29A2-4AB1-958F-19DB0A92D8D7@amacapital.net> <8735v3jujv.ffs@nanos.tec.linutronix.de> <12710fda-1732-ee55-9ac1-0df9882aa71b@samba.org> <59ea3b5a-d7b3-b62e-cc83-1f32a83c4ac2@kernel.dk> <17471c9fec18765449ef3a5a4cddc23561b97f52.camel@trillion01.com> <3df541c3-728c-c63d-eaeb-a4c382e01f0b@kernel.dk> Organization: Trillion01 Inc Content-Type: multipart/mixed; boundary="=-LuIFA0+NKzOxj7b4hLdf" User-Agent: Evolution 3.40.1 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org --=-LuIFA0+NKzOxj7b4hLdf Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On Thu, 2021-05-20 at 00:13 -0400, Olivier Langlois wrote: > I know that my test case isn't conclusive. It is a failed attempt to > capture what my program is doing. > > The priority of investigating my core dump issue has substantially > dropped last week because I did solve my primary issue (A buffer leak > in the provided buffers to io_uring during disconnection). My program > did run for days but it did crash morning without any core dump > again. > It is a very frustrating situation because it would probably be a bug > trivial to diagnostic and fix but without the core, the logs are > opaque > and they just don't give no clue about why the program did crash. > > A key characteristic of my program, it is that it generates at least > 1 > io-worker thread per io_uring instance. As I get more familiar with io_uring source code, I have come to realize that it is practically impossible to not end up with NO io-wq threads. They are created in from io_uring_install_fd() which is called for every instances created. I'm a bit lazy for rebooting my desktop and I am still running 5.11.5 on it. I guess that with this kernel version, the io_uring threads weren't threads belonging to the user process and arent showing with ps by searching for a specific process LWPs. I correctly see all the generated threads when I run the test program on an up-to-date server (5.12.4). I have rewritten the whole test program. It has now become an io_uring multi connection http client (it could make a nice io_uring example program, IMHO). Still no success in reproducing the problem with it. So, I am giving up the idea of reproducing the problem with a showcase program unless I have some clue about how to reproduce it. However, I can reproduce it at will with my real program. So as Linus has suggested, I'll investigate by searching where the PF_IO_WORKER is used. I'll keep the list updated if I discover something. Greetings, --=-LuIFA0+NKzOxj7b4hLdf Content-Disposition: attachment; filename="test_io_uring_coredump.cpp" Content-Type: text/x-c++src; name="test_io_uring_coredump.cpp"; charset="ISO-8859-1" Content-Transfer-Encoding: base64 LyoKICogVGVzdCBwcm9ncmFtIHRvIHJlcHJvZHVjZSBpc3N1ZSBnZW5lcmF0aW5nIGNvcmUgZHVt cHMgd2hpbGUgdXNpbmcgaW9fdXJpbmcuCiAqCiAqIFRvIGNvbXBpbGU6IGcrKyAtcHRocmVhZCB0 ZXN0X2lvX3VyaW5nX2NvcmVkdW1wLmNwcCAtbHVyaW5nCiAqCiAqLwoKI2luY2x1ZGUgPGxpYnVy aW5nLmg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RkbGliLmg+ICAgLy8gZm9yIGFi b3J0KCkKI2luY2x1ZGUgPHVuaXN0ZC5oPiAgIC8vIGZvciBjbG9zZSgpCiNpbmNsdWRlIDxlcnJu by5oPgojaW5jbHVkZSA8ZmNudGwuaD4KI2luY2x1ZGUgPHBvbGwuaD4KI2luY2x1ZGUgPHN0cmlu Zy5oPiAgIC8vIGZvciBzdHJlcnJvcigpCiNpbmNsdWRlIDxtZW1vcnkuaD4gICAvLyBmb3IgbWVt c2V0KCkKI2luY2x1ZGUgPGFycGEvaW5ldC5oPgojaW5jbHVkZSA8c3lzL3NvY2tldC5oPgojaW5j bHVkZSA8bmV0ZGIuaD4KI2luY2x1ZGUgPHN0ZGludC5oPiAgIC8vIGZvciB1aW50MzJfdCwgdWlu dDY0X3QKI2luY2x1ZGUgPHB0aHJlYWQuaD4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxz dHJpbmc+CgojZGVmaW5lIFFEIDI1NgojZGVmaW5lIEJHSUQxIDAKI2RlZmluZSBCR0lEMiAxCiNk ZWZpbmUgUE9SVDEgMTk3NQojZGVmaW5lIFBPUlQyIDE5NzYKI2RlZmluZSBCVUZTWiA1KjQwOTYK CmVudW0gewogICAgSU9VUklOR19QT0xMX0FERCwKICAgIElPVVJJTkdfUE9MTF9SRU1PVkUsCiAg ICBJT1VSSU5HX1BST1ZfQlVGLAogICAgSU9VUklOR19CVUZfUkVBRCwKICAgIElPVVJJTkdfV1JJ VEUKfTsKCnN0YXRpYwpjb25zdCBjaGFyICpJb19VcmluZ19PcFR5cGVUb1N0cihjaGFyIHR5cGUp CnsKICAgIGNvbnN0IGNoYXIgKnJlczsKICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgIGNhc2Ug SU9VUklOR19QT0xMX0FERDoKICAgICAgICAgICAgcmVzID0gIklPVVJJTkdfUE9MTF9BREQiOwog ICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIElPVVJJTkdfUE9MTF9SRU1PVkU6CiAgICAg ICAgICAgIHJlcyA9ICJJT1VSSU5HX1BPTExfUkVNT1ZFIjsKICAgICAgICAgICAgYnJlYWs7CiAg ICAgICAgY2FzZSBJT1VSSU5HX1BST1ZfQlVGOgogICAgICAgICAgICByZXMgPSAiSU9VUklOR19Q Uk9WX0JVRiI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgSU9VUklOR19CVUZfUkVB RDoKICAgICAgICAgICAgcmVzID0gIklPVVJJTkdfQlVGX1JFQUQiOwogICAgICAgICAgICBicmVh azsKICAgICAgICBjYXNlIElPVVJJTkdfV1JJVEU6CiAgICAgICAgICAgIHJlcyA9ICJJT1VSSU5H X1dSSVRFIjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDo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gICAgICAgICAgICAgICAgQnVmZmVyTWFuYWdlciAmYnVmbWdyKQp7CiAg ICBjaGFyIHR5cGU7CiAgICBpbnQgIGZkLCBiaWQ7CiAgICB1aW50MzJfdCBjbGllbnRJZDsKICAg IGludCByZXMgPSBjcWUtPnJlczsKCiAgICBpb3VyaW5nX2RlY29kZV91c2VyX2RhdGEoY3FlLT51 c2VyX2RhdGEsICZ0eXBlLCAmZmQsICZjbGllbnRJZCk7CiAgICBzd2l0Y2ggKHR5cGUpIHsKICAg ICAgICBjYXNlIElPVVJJTkdfUE9MTF9BREQ6CiAgICAgICAgICAgIGlmIChtX3N0YXRlICE9IENP Tk5FQ1RJTkcpIHsKICAgICAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiY2xpZW50ICVkOiB1 bmV4cGVjdGVkIElPVVJJTkdfUE9MTF9BREQgY29tcGxldGlvblxuIiwgY2xpZW50SWQpOwogICAg ICAgICAgICAgICAgYWJvcnQoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyBjbGVhciB0 aGUgT19OT05CTE9DSyBmbGFnCiAgICAgICAgICAgIGZjbnRsKG1fZmQsIEZfU0VURkwsIDApOwog ICAgICAgICAgICAvKgogICAgICAgICAgICAgKiBTZXR1cCB0aGUgbmV4dCByZWFkIGJlZm9yZSBz ZW5kaW5nIHRoZSByZXF1ZXN0LgogICAgICAgICAgICAgKiBNYXliZSBpdCBpcyBoYXZpbmcgbXVs dGlwbGUgY29uY3VycmVudCBvcGVyYXRpb25zIG9uIHRoZSBzYW1lCiAgICAgICAgICAgICAqIGZk IHRoYXQgaXMgdHJpZ2dlcmluZyB0aGUgaW8gdGhyZWFkIHNwYXduLgogICAgICAgICAgICAgKi8K ICAgICAgICAgICAgaW5pdEJ1ZlNlbGVjdFJlYWQocmluZywgbV9mZCwgYnVmbWdyLmdldE1heFN6 KCksIGJ1Zm1nci5nZXRHaWQoKSwgY2xpZW50SWQpOwogICAgICAgICAgICBzZW5kUmVxdWVzdChy aW5nLCBjbGllbnRJZCk7CiAgICAgICAgICAgIG1fc3RhdGUgPSBXQUlUX1JFUExZOwogICAgICAg ICAgICBicmVhazsKICAgICAgICBjYXNlIElPVVJJTkdfUE9MTF9SRU1PVkU6CiAgICAgICAgICAg IGZwcmludGYoc3RkZXJyLCAiY2xpZW50ICVkOiB1bmV4cGVjdGVkIElPVVJJTkdfUE9MTF9SRU1P VkUgY29tcGxldGlvblxuIiwgY2xpZW50SWQpOwogICAgICAgICAgICBhYm9ydCgpOwogICAgICAg ICAgICBicmVhazsKICAgICAgICBjYXNlIElPVVJJTkdfUFJPVl9CVUY6CiAgICAgICAgICAgIGlm IChyZXMgPCAwKSB7CiAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgImNsaWVudCAlZDog dW5leHBlY3RlZCBJT1VSSU5HX1BST1ZfQlVGIGZhaWx1cmU6ICglZCkgJXNcbiIsCiAgICAgICAg ICAgICAgICAgICAgICAgIGNsaWVudElkLCAtcmVzLCBzdHJlcnJvcigtcmVzKSk7CiAgICAgICAg ICAgICAgICBhYm9ydCgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAg IGNhc2UgSU9VUklOR19CVUZfUkVBRDoKICAgICAgICAgICAgaWYgKHJlcyA8PSAwKSB7CiAgICAg ICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgImNsaWVudCAlZDogdW5leHBlY3RlZCBJT1VSSU5H X0JVRl9SRUFEIHJlczogJWRcbiIsCiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudElkLCBy ZXMpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgcmVj dlJlcGx5KHJpbmcsIGNxZSwgYnVmbWdyKTsKICAgICAgICAgICAgICAgIC8vIFJlbG9hZCB0aGUg cmVhZAogICAgICAgICAgICAgICAgaW5pdEJ1ZlNlbGVjdFJlYWQocmluZywgbV9mZCwgYnVmbWdy LmdldE1heFN6KCksIGJ1Zm1nci5nZXRHaWQoKSwgY2xpZW50SWQpOwogICAgICAgICAgICB9CiAg ICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgSU9VUklOR19XUklURToKICAgICAgICAgICAg ZnByaW50ZihzdGRlcnIsICJjbGllbnQgJWQ6IHJlcXVlc3QgdHggY29tcGxldGVkOiAlZFxuIiwg Y2xpZW50SWQsIHJlcyk7CiAgICAgICAgICAgIGJyZWFrOwogICAgfQp9CgojZGVmaW5lIE5VTUNM SUVOVFMgNgoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKewogICAgaW50IHJlczsK ICAgIHN0cnVjdCBpb191cmluZ19wYXJhbXMgcGFyYW1zOwogICAgc3RydWN0IGlvX3VyaW5nIHJp bmc7CiAgICAKICAgIG1lbXNldCgmcGFyYW1zLCAwLCBzaXplb2YocGFyYW1zKSk7CgogICAgaWYg KGlvX3VyaW5nX3F1ZXVlX2luaXRfcGFyYW1zKFFELCAmcmluZywgJnBhcmFtcykgPCAwKSB7CiAg ICAgICAgZnByaW50ZihzdGRlcnIsICJpb191cmluZ19xdWV1ZV9pbml0X3BhcmFtcygpIGZhaWxl ZDogKCVkKSAlc1xuIiwgZXJybm8sIHN0cmVycm9yKGVycm5vKSk7CiAgICAgICAgcmV0dXJuIHJl czsKICAgIH0KICAgIEJ1ZmZlck1hbmFnZXIgYnVmbWdyKCZyaW5nLCBUSFJFQURfTUFYX0ZEKkJJ T19SSU5HX1NaLCBCVUZTWiwgQkdJRDEpOwoKICAgIGNvbnN0IGNoYXIgKnNlcnZlcnNbTlVNQ0xJ RU5UU10gPSB7CiAgICAgICAgImdvb2dsZS5jb20iLAogICAgICAgICJmYWNlYm9vay5jb20iLAog ICAgICAgICJ0d2l0dGVyLmNvbSIsCiAgICAgICAgInd3dy5jbG91ZGZsYXJlLmNvbSIsCiAgICAg ICAgImtlcm5lbC5vcmciLAogICAgICAgICJwaG9yb25peC5jb20iCiAgICB9OwoKICAgIEh0dHBD bGllbnQgY2xpZW50c1tOVU1DTElFTlRTXTsKCiAgICAvKgogICAgICogR2l2ZSB0aGUgdGVzdGVy CiAgICAgKi8KICAgIHNsZWVwKDEwKTsKICAgIAogICAgZm9yICh1aW50MzJfdCBpID0gMDsgaSA8 IE5VTUNMSUVOVFM7ICsraSkgewogICAgICAgIGNsaWVudHNbaV0uaW5pdGlhdGUoJnJpbmcsIHNl cnZlcnNbaV0sICIvIiwgaSk7CiAgICB9CgogICAgd2hpbGUgKDEpIHsKICAgICAgICBpb191cmlu Z19zdWJtaXRfYW5kX3dhaXQoJnJpbmcsIDEpOwogICAgICAgIHVuc2lnbmVkIGNvbXBsZXRlZCA9 IDA7CiAgICAgICAgdW5zaWduZWQgaGVhZDsKICAgICAgICBzdHJ1Y3QgaW9fdXJpbmdfY3FlICpj cWU7CiAgICAgICAgaW9fdXJpbmdfZm9yX2VhY2hfY3FlKCZyaW5nLCBoZWFkLCBjcWUpIHsKICAg ICAgICAgICAgKytjb21wbGV0ZWQ7CiAgICAgICAgICAgIGNoYXIgdHlwZTsKICAgICAgICAgICAg aW50ICBmZCwgYmlkOwogICAgICAgICAgICB1aW50MzJfdCBjbGllbnRJZDsKICAgICAgICAgICAg aW91cmluZ19kZWNvZGVfdXNlcl9kYXRhKGNxZS0+dXNlcl9kYXRhLCAmdHlwZSwgJmZkLCAmY2xp ZW50SWQpOwogICAgICAgICAgICBpZiAoY2xpZW50SWQgPCBOVU1DTElFTlRTKSB7CiAgICAgICAg ICAgICAgICBjbGllbnRzW2NsaWVudElkXS5wcm9jZXNzQ29tcGxldGlvbigmcmluZywgY3FlLCBi dWZtZ3IpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAg LyoKICAgICAgICAgICAgICAgICAqIFRoZSBvbmx5IG9wZXJhdGlvbiBmb3Igd2hpY2ggd2UgZG9u J3QgYXNzaWduIGEgY2xpZW50IGlkIGlzIElPUklOR19PUF9QUk9WSURFX0JVRkZFUlMKICAgICAg ICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgaWYgKHR5cGUgIT0gSU9VUklOR19QUk9WX0JV RikgewogICAgICAgICAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiVW5leHBlY3RlZCBjb21w bGV0aW9uIGV2ZW50IHdpdGggbm8gY2xpZW50IGFzc29jaWF0aW9uOiAlc1xuIiwKICAgICAgICAg ICAgICAgICAgICAgICAgICAgIElvX1VyaW5nX09wVHlwZVRvU3RyKHR5cGUpKTsKICAgICAgICAg ICAgICAgICAgICBhYm9ydCgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxz ZSBpZiAoY3FlLT5yZXMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIs ICJ1bmV4cGVjdGVkIElPVVJJTkdfUFJPVl9CVUYgZmFpbHVyZTogKCVkKSAlc1xuIiwKICAgICAg ICAgICAgICAgICAgICAgICAgICAgIC1jcWUtPnJlcywgc3RyZXJyb3IoLWNxZS0+cmVzKSk7CiAg ICAgICAgICAgICAgICAgICAgYWJvcnQoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAg fQogICAgICAgIH0KICAgICAgICBpZiAoY29tcGxldGVkKSB7CiAgICAgICAgICAgIGlvX3VyaW5n X2NxX2FkdmFuY2UoJnJpbmcsIGNvbXBsZXRlZCk7CiAgICAgICAgfQogICAgfQplcnIyOgogICAg aW9fdXJpbmdfcXVldWVfZXhpdCgmcmluZyk7CmVycjE6CiAgICByZXR1cm4gcmVzOwp9Cg== --=-LuIFA0+NKzOxj7b4hLdf--