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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 AC129C43381 for ; Fri, 29 Mar 2019 21:46:49 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CAE221773 for ; Fri, 29 Mar 2019 21:46:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CAE221773 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vt.edu Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1h9zKE-0008MB-Np; Fri, 29 Mar 2019 17:46:10 -0400 Received: from omr2.cc.ipv6.vt.edu ([2607:b400:92:8400:0:33:fb76:806e] helo=omr2.cc.vt.edu) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h9zKB-0008M3-Bp for kernelnewbies@kernelnewbies.org; Fri, 29 Mar 2019 17:46:07 -0400 Received: from mr1.cc.vt.edu (mr1.cc.vt.edu [IPv6:2607:b400:92:8300:0:31:1732:8aa4]) by omr2.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x2TLk3vw009126 for ; Fri, 29 Mar 2019 17:46:04 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mr1.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x2TLjwkA004971 for ; Fri, 29 Mar 2019 17:46:03 -0400 Received: by mail-qt1-f200.google.com with SMTP id n13so3671583qtn.6 for ; Fri, 29 Mar 2019 14:46:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:date:message-id; bh=3pf8+14eJuIJszSplWChL06xbO62pxU8v2sNs01maJE=; b=DSMqpWmi3YULapJkO6WE3xskkoxxdQ6Rvw8ZdEfG3o1hNF+i7lOvDPpJFIfaJAOv7/ gR5ecbIdz3I9f8QUsbAvOJd1jYpQXaLodgnVHQVeApHZA8wDU7LoAXocKX31TkZkSMXz x2YTafvCHM0XTYVAkH9HRXSuiPN0AyfOCWAvzbbtYNHfwZsWqm/4kvpy1U2wVXaGyCTi w6lo7k+59TliqrHFeu1EApna7s6D0DA2FoNJ1iFQfFh1uCEY4OvGLyyU8tNn1X7pUykY DgGxDm4MIcUIYGvzq1B59UnQz1Ez5+zI2o1AVkNAr5Xlh+lOD88wxZmaVCMqWv7a1oA9 zcfg== X-Gm-Message-State: APjAAAWRaezHU5RjAe4ldW1P3jlXN8PgMmra54D7SMDof5046zKvBVsF r/FeXfJoG5s0HL6ZAw+Mp4L0tEJtdubtPNIexbix70ZUp2nlR8ZsNT4NusOxeGIGj5fTyIPcN48 /22TtPbSBmzWJuGBR2ylntxptVEEBjJANZVOTtk0= X-Received: by 2002:a37:e315:: with SMTP id y21mr41459272qki.233.1553895958484; Fri, 29 Mar 2019 14:45:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOZsuSNOR6rrVvWbs8xL763zXYMF4pERkyfLOIro0ztPDiiC1p8s9ac4ReAO8PuU37rI2/JQ== X-Received: by 2002:a37:e315:: with SMTP id y21mr41459246qki.233.1553895957873; Fri, 29 Mar 2019 14:45:57 -0700 (PDT) Received: from turing-police ([2601:5c0:c001:4341::208]) by smtp.gmail.com with ESMTPSA id v52sm2232075qth.4.2019.03.29.14.45.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Mar 2019 14:45:56 -0700 (PDT) From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Google-Original-From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Greg KH Subject: Re: Unexpected scheduling with mutexes In-reply-to: <20190329200158.GF12004@kroah.com> References: <20190329200158.GF12004@kroah.com> Mime-Version: 1.0 Date: Fri, 29 Mar 2019 17:45:56 -0400 Message-ID: <5772.1553895956@turing-police> Cc: Martin Christian , kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Fri, 29 Mar 2019 21:01:58 +0100, Greg KH said: > But if you are trying to somehow create a real api that you have to > enforce the passing off of writing data from two different character > devices in an interleaved format, you are doing this totally wrong, as > this is not going to work with a simple mutex, as you have found out. There's almost always an even more fundamental issue here - I've seen plenty of people attempt to do this sort of thing. But invariably, they have little to no explanation of what semantics they think are correct. I'm not sure who are crazier - the people who try to do kernel-side locking for "exclusive" use of a device, or the people who don't understand why having 3 different programs trying to talk to /dev/ttyS0 at once will only lead to tearns and anguish... (Though recently, I discovered that there are no bad ideas so obvious that somebody won't try to re-invent them. I caught a software package that *really* should know better using "does DBus have an entry for this object?" as a lock.) > Try to take USB out of the picture as well as userspace, and try running > two kernel threads trying to grab a mutex and then print out "A" or "B" > to the kernel log and then give it up. Is that output nicely > interleaved or is there some duplicated messages.[1] > [1] Extra bonus points for those that recognize this task... Been there, done that, got the tire marks to prove it. :) _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies