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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 791E9C47095 for ; Mon, 7 Jun 2021 23:36:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C3F8610E5 for ; Mon, 7 Jun 2021 23:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbhFGXiM (ORCPT ); Mon, 7 Jun 2021 19:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhFGXiK (ORCPT ); Mon, 7 Jun 2021 19:38:10 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C367C061574 for ; Mon, 7 Jun 2021 16:36:05 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id z22so8528068ljh.8 for ; Mon, 07 Jun 2021 16:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Bj+3pmdBLjat38YzGIwe/LbSm4GNIavhFcUTV5mhCVk=; b=Sbo5NkDjodBKpzQgpBDWnnVyo+sOZY4L/bffARKmA/haCwh+jHPisbJEH8wkyItgYD q20QmGC4mQZeg0O7HcHaRDzioKDHpaLLl/EA2ocn26ly6NkvA5Xtd+KpbnCRwrd+1ydU E0OLAkEREa+xQUjv3yGnFZMGWR69WZVuXaWBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Bj+3pmdBLjat38YzGIwe/LbSm4GNIavhFcUTV5mhCVk=; b=hOCK4iAifdZLajugxXyGFo2Ue6Nvs5ypC0Vs+wLq0a59J6u7kpXxEixrF4vWEuKAE2 iBkgVcIf7b950QOo0cc/cidfpcfOpYVWivB01ZarwdD8vvRGILMwRRxWWCmz3c7F3/l6 HYvv0B7aemIIwkugnqwzzj7TpGXP80+S3HzS0B5Wzx8yuo6tgdoClk419tgTq1bdpys2 NysyxGowENjSlUWsU2klGjf5kn/xvSmLmr4OZncwXrHxfZnJr645JFHH3ZN2mNJj4ZkV CPjnNVlZ6I3Jx8J3c0DREhHPu4LLRH46UrLd8TyQPgNP3aAsBdmwbOwGEANKxBXyII5J rd7g== X-Gm-Message-State: AOAM532p971V7qCq2eC+D+2+xhM43FmDvGGbNkRenu8F3BAuyhlpK3NX IorxjuG48MiuuVrLFTq++V1gu7IbrylPzNU+HJA= X-Google-Smtp-Source: ABdhPJwA7IF48Ogu2XaRNYB3R9sHuofhHO9ciGGL5cgGeB3ZXWMxTn5UJqN9iLUwZiV7Kc4LPMalmQ== X-Received: by 2002:a05:651c:1132:: with SMTP id e18mr15818968ljo.386.1623108963576; Mon, 07 Jun 2021 16:36:03 -0700 (PDT) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id e20sm1203041ljk.67.2021.06.07.16.36.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Jun 2021 16:36:02 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id w33so29113044lfu.7 for ; Mon, 07 Jun 2021 16:36:02 -0700 (PDT) X-Received: by 2002:ac2:43b9:: with SMTP id t25mr13531788lfl.253.1623108962242; Mon, 07 Jun 2021 16:36:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Mon, 7 Jun 2021 16:35:46 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCHSET] iov_iter work To: Al Viro Cc: Christoph Hellwig , linux-fsdevel , Linux Kernel Mailing List , David Sterba , Miklos Szeredi , Anton Altaparmakov , David Howells , Matthew Wilcox , Pavel Begunkov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 7, 2021 at 3:01 PM Linus Torvalds wrote: > > (b) on all the common non-SET_FS architectures, kernel threads using > iov_iter_init() wouldn't work anyway, because on those architectures > it would always fill the thing in with an iov, not a kvec. Thinking more about this thing, I think it means that what we *should* do is simply just void iov_iter_init(struct iov_iter *i, unsigned int direction, const struct iovec *iov, unsigned long nr_segs, size_t count) { WARN_ON_ONCE(direction & ~(READ | WRITE)); iWARN_ON_ONCE(uaccess_kernel()); *i = (struct iov_iter) { .iter_type = ITER_IOVEC, .data_source = direction, .iov = iov, .nr_segs = nr_segs, .iov_offset = 0, .count = count }; } because filling it with a kvec is simply wrong. It's wrong exactly due to the fact that *if* we have a kernel thread, all the modern non-SET_FS architectures will just ignore that entirely, and always use the iov meaning. So just do that WARN_ON_ONCE() to show that something is wrong (the exact same way that the direction thing needs to be proper), and then just fill it in as an ITER_IOVEC. Because handling that legacy KERNEL_DS case as a KVEC is actively not right anyway and doesn't match what a kernel thread would do on x86 or arm64, so don't even try. Linus