Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp16839imm; Tue, 24 Jul 2018 13:07:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfVFACY2K//hH6Bsq/kR7nxJKZQKjHomgwAyftUS4soZf2PL0q2fxn7GQKYf7aYmWDO4fBt X-Received: by 2002:a17:902:b08a:: with SMTP id p10-v6mr18082335plr.217.1532462860385; Tue, 24 Jul 2018 13:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532462860; cv=none; d=google.com; s=arc-20160816; b=ca5MXOOlJJQDqS2P6YdYUbAIh7FZLUJCqzOS9nF3HOVNzwrEZ0I5JW25mVbE/ZoQSt Lz6wzm9rDEhOP6PQcHhq62RqMSGre5MHNG5ABYh3BdP/b7G8iQxTSJQE0qTGUDJJGsyu Mki/+Uag6plsTDz6i87yRQqUn5DpsaFUsBI9tXUyLgGJzQcvoeBC+4pBIl61DlN2a8s1 3XYl5QRifPdyT4TISnGkkDNYc017DJ3UyKY9YeKHH+oqynM+dDNrvmI50TeysMV+0Pkt JHasHPBOTpxK/dhWOzY1HQM3U18gj8ujhw6XERvvvcf/b4LQ80In1Rg6TpJvIz5tFtzZ q3Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=lUmz2N6hIf1oVUoXADdpfK/WnP6D5jA7OGESUUm7OhA=; b=jtrBT0mJhvEpMk80LTV0OhXmPvsTmQfmeKi7U2Woq/NPqCQeQz352p5PSx7ueaAg4R KX5dXXx92iClQ4xxnxjWwcuystU3loJ5ISEuaLClIRMAr5PunsBa9zTK0QngwcaUU/FJ y5SMLZjrKNRQdKB5v/9n8CnaGApLmdt0lw8JIDwKOyqjQUj4FjTv3yT8XM0yKD6G42uq h2j89Uu9z5AnKsJ1I7qv2EiOUkWzwbcFP/d5zxp6HRvJ5OjoyQUCiCJ8efGOT/2Ed8xH UKMgDiL8ZrPz/rA1YOZajWYFnt7wDYEGvKMX5kdsuHbZg1k9oFI1mBqKL5m7JakfqRak VF9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si12424625pge.589.2018.07.24.13.07.21; Tue, 24 Jul 2018 13:07:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388667AbeGXVNr (ORCPT + 99 others); Tue, 24 Jul 2018 17:13:47 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:36660 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388604AbeGXVNr (ORCPT ); Tue, 24 Jul 2018 17:13:47 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fi3Z0-0000jx-9j; Tue, 24 Jul 2018 14:05:42 -0600 Received: from [97.119.167.31] (helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fi3Yz-0005Ij-M7; Tue, 24 Jul 2018 14:05:42 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , Linux Kernel Mailing List , Wen Yang , majiang References: <87efft5ncd.fsf_-_@xmission.com> <20180724032419.20231-20-ebiederm@xmission.com> <874lgo5xdg.fsf@xmission.com> Date: Tue, 24 Jul 2018 15:05:28 -0500 In-Reply-To: (Linus Torvalds's message of "Tue, 24 Jul 2018 11:29:39 -0700") Message-ID: <87fu084cxj.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fi3Yz-0005Ij-M7;;;mid=<87fu084cxj.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18JvOLrXCAvOgVztUGM6MNx+0tUsjWqFeM= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa06.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,T_TooManySym_02, XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4999] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 227 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.6 (1.2%), b_tie_ro: 1.84 (0.8%), parse: 0.75 (0.3%), extract_message_metadata: 12 (5.5%), get_uri_detail_list: 1.54 (0.7%), tests_pri_-1000: 7 (3.1%), tests_pri_-950: 1.21 (0.5%), tests_pri_-900: 1.01 (0.4%), tests_pri_-400: 27 (12.1%), check_bayes: 26 (11.5%), b_tokenize: 10 (4.5%), b_tok_get_all: 8 (3.3%), b_comp_prob: 3.8 (1.7%), b_tok_touch_all: 2.2 (1.0%), b_finish: 0.66 (0.3%), tests_pri_0: 168 (73.9%), check_dkim_signature: 0.49 (0.2%), check_dkim_adsp: 2.5 (1.1%), tests_pri_500: 4.3 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 20/20] signal: Don't restart fork when signals come in. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Tue, Jul 24, 2018 at 10:58 AM Eric W. Biederman > wrote: >> >> Yes you are quite right. Easy enough to fix, but it definitely needs >> to be fixed. >> >> I will respin. > > Would you mind trying a slightly different approach for this? > > How about moving the "copy_signal()" and "copy_sighandler()" cases up > to fairly early in the "copy_process()" function (and clean up late, > obviously). > > Then, instead of that "struct multiprocess_signals" thing, just add a > "struct hlist_node node" to "struct signal" itself, and add it to the > multiprocess hlist there. > > And then you can just remove it in bad_fork_cleanup_signal. > > Does this make "struct signal" a bit larger? Yes, but it's not a huge > deal. We *could* make is some union with existing fields if we cared. > > But I think it would make the code *much* more understandable, and it > would allow us to not have that "sigpending" copy, because you can > just populate the final "signal->shared_pending" directly. > > Hmm? I don't like it. What I hear you asking is moving up copy_signal copy_sighand copy_creds and alloc_pid, and anything else that signal delivery might depend on. Then in send_signal running __send_signal in a loop first for the forking process and then for every process that is currently in the middle of fork. It feels like this gets us much later in fork, and there is a lot more code to move and review. Which to some extent makes us more susceptible to periodic signals, as more work will be thrown away and have to be redone. Plus it makes the whole thing susceptible to signal delivery growing some additional dependency (perhaps cgroups?) and that getting missed and never noticed until someone manages to time a sending a signal just right. I really want something very simple and straight forward because I don't see us testing or hitting this code path much in practice. Moving this into the middle of fork and adding more depedencies does not seem like it will be that kind of straight forward. Eric